Skip to content

Commit

Permalink
fix(android): launchActivity intent for quick actions (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
helenaford authored Mar 2, 2022
1 parent c115750 commit 6b947ac
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,26 @@ static void setIntentExtras(
}
}

static boolean shouldCreateLaunchActivityIntent(
NotificationAndroidPressActionModel pressActionModel) {
if (pressActionModel == null) {
return false;
}

if (pressActionModel.getLaunchActivity() == null
&& pressActionModel.getMainComponent() == null) {
return false;
}

return true;
}

static Intent createLaunchActivityIntent(
Context context, int notificationId, NotificationAndroidPressActionModel pressActionModel) {
if (!shouldCreateLaunchActivityIntent(pressActionModel)) {
return null;
}

try {
Intent launchActivityIntent =
context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
Expand Down
4 changes: 4 additions & 0 deletions docs/react-native/docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ next: /react-native/docs/usage
previous: /react-native/docs/installation
---

## 5.0.1
- **[Android]**: Fixes an issue where quick actions always opens the app on Android 12 (Fixes [#315](https://github.com/invertase/notifee/issues/315)).
- **[Android]**: Fixes an issue where a quick action with an id of `default` failed to open the app.

## 5.0.0
- **[Android/iOS] BREAKING CHANGE**: Added support for checking permissions on Android which introduces a breaking change to `requestPermission` and `getNotificationSettings` APIs.

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bb8043b39eb4ded26b11bae6314e8c04
5ba08f77d8b2405ac3a6cdfa6b5c03eb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c20c6b22b9c676af23bce6ea5586917fc71ba34c
078dafeef54b6887c7e1e566c4f37daf6f25b816
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b75f2bf431ab98d291e4406e0cfdcb71ee0b613639af7dceef4909df3e8b9946
f30764ec7419061ca7aa2a51993dd85309ec054c48d6bded4e8bf36d38297215
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10f0c81df184fea08c82914c514f93acb19336c74a4cd161e93e5541afa4dd7a6e377400a063e3af9fa548ed2383765f263e1a9f61a17984e878391ecf50325c
9a652b59f07f88bc58a61f3bfaf2f4f4203b3257a66de389d18e35d3dceb17b73e6d66674a8c113e93dd2ea14d7bfccaab3637e416514821e70da2223f31c632
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<versions>
<version>202108261754</version>
</versions>
<lastUpdated>20220302014936</lastUpdated>
<lastUpdated>20220302122031</lastUpdated>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e8b37ba27c2d8ae3bdbaab8d0b34eb34
f35a3fa69fc1c2ea2594551d590d29bc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b771fefe48727fa2f325b58ffd752c5fc1674fb0
3ca305166904c416866bc31493e80949df45774b
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f01b9fc7bd41d3e6aeef6bfc1ac7c15d777f2fb95634503127e5bd9098534906
69df89b8326e68ce4edecb1250338567b87112468140057130eec81e0c605d59
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cb3c5910c73d4d7e749434cc1cba629a4e4afc761e01d497838a1563c569aa8194dbbc034f185dee66b3ea1cb51734ca6f24e3e3ddf6264509deda24dfe778ef
6c495cee27970fe59a19e452415bce2b4768be076dedbecb9a9afaedc33c866887e556bea5765a3b99eebcd6ef5a4d5100acc0ab58210cb6b7856854a441213e
2 changes: 1 addition & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@notifee/react-native",
"version": "5.0.0",
"version": "5.0.1",
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
"description": "Notifee - a feature rich notifications library for React Native.",
"main": "dist/index.js",
Expand Down
14 changes: 8 additions & 6 deletions packages/react-native/src/validators/validateAndroidAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ export default function validateAndroidAction(action: AndroidAction): AndroidAct
throw new Error("'action' expected an object value.");
}

if (!isString(action.title) || !action.title) {
throw new Error("'action.title' expected a string value.");
}

let pressAction;

try {
validateAndroidPressAction(action.pressAction);
pressAction = validateAndroidPressAction(action.pressAction);
} catch (e: any) {
throw new Error(`'action' ${e.message}.`);
}

if (!isString(action.title) || !action.title) {
throw new Error("'action.title' expected a string value.");
}

const out: AndroidAction = {
pressAction: action.pressAction,
title: action.title,
pressAction,
};

if (objectHasProperty(action, 'icon') && !isUndefined(action.icon)) {
Expand Down
11 changes: 2 additions & 9 deletions tests_react_native/example/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ export const notifications: { key: string; notification: Notification | Notifica
title: 'Reply, Open & Cancel',
icon: 'https://invertase.io/icons/icon-48x48.png',
pressAction: {
id: 'first_action',

// reactComponent: 'test_component',
id: 'default',
},
input: true,
// input: {
Expand All @@ -138,13 +136,8 @@ export const notifications: { key: string; notification: Notification | Notifica
icon: 'https://invertase.io/icons/icon-48x48.png',
pressAction: {
id: 'second_action',
// mainComponent: 'test_component',
mainComponent: 'test_component',
},
// input: {
// choices: ['You'],
// allowFreeFormInput: true,
// placeholder: 'Second Input',
// },
},
{
title: 'Nothing',
Expand Down

0 comments on commit 6b947ac

Please sign in to comment.