amplify-js: Sometimes App doesn't Open on android after click on notification
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React Native
Amplify APIs
Analytics, Push Notifications
Amplify Categories
notifications
Environment information
# Put output below this line
System:
OS: macOS 12.2.1
CPU: (8) x64 Apple M1
Memory: 22.57 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.16.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.24.2 - ~/Desktop/Villeo/node_modules/.bin/npm
Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman
npmPackages:
@aws-amplify/pushnotification: ^4.1.3 => 4.2.14
@babel/core: ^7.13.16 => 7.15.8
@babel/runtime: ^7.13.17 => 7.15.4
@mdi/js: ^5.9.55 => 5.9.55
@mdi/react: ^1.5.0 => 1.5.0
@react-native-async-storage/async-storage: ^1.15.4 => 1.15.9
@react-native-community/eslint-config: ^2.0.0 => 2.0.0
@react-native-community/netinfo: ^6.2.1 => 6.2.1
@react-native-community/progress-bar-android: ^1.0.4 => 1.0.4
@react-native-community/progress-view: ^1.3.1 => 1.3.1
@react-native-community/push-notification-ios: ^1.0.3 => 1.10.1 (1.0.3)
@react-native-picker/picker: ^1.15.0 => 1.16.8
@react-native/normalize-color: ^2.0.0 => 2.0.0 (1.0.0)
@react-navigation/bottom-tabs: ^5.11.10 => 5.11.15
@react-navigation/drawer: ^5.12.5 => 5.12.9
@react-navigation/native: ^5.9.4 => 5.9.8
@react-navigation/stack: ^5.14.4 => 5.14.9
Basic: 0.0.1
HelloWorld: 0.0.1
PDFExample: 0.0.1
amazon-cognito-identity-js: ^4.6.0 => 4.6.3 (5.2.0)
aws-amplify: ^4.3.1 => 4.3.2
aws-amplify-react-native: ^4.3.2 => 4.3.3
aws-sdk: ^2.946.0 => 2.1005.0
babel-jest: ^26.6.3 => 26.6.3
eslint: 7.25.0 => 7.25.0
hermes-inspector-msggen: 1.0.0
install: ^0.13.0 => 0.13.0
jest: ^26.6.3 => 26.6.3
lodash: ^4.17.21 => 4.17.21
metro: ^0.66.0 => 0.66.2 (0.64.0)
metro-config: ^0.66.0 => 0.66.2 (0.64.0)
metro-react-native-babel-preset: ^0.66.0 => 0.66.2 (0.64.0)
moment: ^2.29.1 => 2.29.1
npm: ^7.11.1 => 7.24.2
npm-check-updates: ^11.5.4 => 11.8.5
react: 17.0.2 => 17.0.2
react-native: 0.64.0 => 0.64.0
react-native-action-button: ^2.8.5 => 2.8.5
react-native-calendars: ^1.1259.0 => 1.1267.0
react-native-customized-image-picker: ^1.2.1 => 1.2.2
react-native-dropdown-picker: ^4.0.9 => 4.0.9
react-native-elements: ^3.4.2 => 3.4.2
react-native-fast-image: ^8.5.11 => 8.5.11
react-native-gesture-handler: ^1.10.3 => 1.10.3
react-native-get-location: ^2.1.1 => 2.1.2
react-native-get-random-values: ^1.7.0 => 1.7.0
react-native-image-picker: ^3.8.1 => 3.8.1
react-native-image-zoom-viewer: ^3.0.1 => 3.0.1
react-native-loading-spinner-overlay: ^3.0.0 => 3.0.0
react-native-maps: ^0.30.2 => 0.30.2
react-native-pdf: ^6.3.0 => 6.3.0
react-native-permissions: ^3.0.5 => 3.0.5
react-native-push-notification: ^8.1.1 => 8.1.1
react-native-rate: ^1.2.9 => 1.2.9
react-native-reanimated: ^2.1.0 => 2.2.2
react-native-render-html: ^6.0.4 => 6.1.0
react-native-safe-area-context: ^3.4.1 => 3.4.1
react-native-screens: ^3.1.1 => 3.8.0
react-native-share: ^7.3.3 => 7.3.3
react-native-snap-carousel: ^3.9.1 => 3.9.1
react-native-splash-screen: ^3.2.0 => 3.2.0
react-native-svg: ^12.1.1 => 12.3.0
react-native-svg-transformer: ^0.14.3 => 0.14.3
react-native-tip: ^0.0.18 => 0.0.18
react-native-vector-icons: ^8.1.0 => 8.1.0 (7.1.0)
react-native-video: ^5.2.0 => 5.2.0
react-native-video-player: ^0.12.0 => 0.12.0
react-native-webview: ^11.17.2 => 11.17.2
react-redux: ^7.2.4 => 7.2.5
react-test-renderer: 17.0.2 => 17.0.2
react-xml-parser: ^1.1.8 => 1.1.8
redux: ^4.1.0 => 4.1.1
redux-persist: ^6.0.0 => 6.0.0
redux-persist/integration/react: undefined ()
rn-fetch-blob: ^0.12.0 => 0.12.0
svg-path-bbox: ^1.0.1 => 1.0.1
uuid: ^8.3.2 => 8.3.2 (3.4.0, 3.3.2)
npmGlobalPackages:
@aws-amplify/cli: 7.6.26
aws-amplify-react-native: 5.0.1
aws-amplify: 4.0.3
expo-cli: 4.3.2
graphql: 14.7.0
ios-deploy: 1.11.4
npm-check-updates: 11.5.4
npm: 7.6.3
react-native-cli: 2.0.1
yarn: 1.22.10
Describe the bug
Sometimes when a user receives a notification, clicking on it does nothing even though it is supposed to open app.
This is not really frequent hovewer we are trying to solve this issue.
Expected behavior
The application should open, using a deep link or just starting its normal way
Reproduction steps
As i said this bug is really infrequent, i beleive it happens only on certains models (see below)
i haven’t been able to reproduce it on my devices.
Code Snippet
// Put your code below this line.
Log output
Here are the logs that google play console provides me :
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:4358)
at android.app.ActivityThread.access$2500 (ActivityThread.java:296)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2238)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loop (Looper.java:213)
at android.app.ActivityThread.main (ActivityThread.java:8178)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1101)
Caused by: java.lang.NullPointerException:
at com.amazonaws.amplify.pushnotification.modules.RNPushNotificationJsDelivery.sendEvent (RNPushNotificationJsDelivery.java:2)
at com.amazonaws.amplify.pushnotification.modules.RNPushNotificationJsDelivery.emitNotificationOpened (RNPushNotificationJsDelivery.java:37)
at com.amazonaws.amplify.pushnotification.modules.RNPushNotificationBroadcastReceiver.onReceive (RNPushNotificationBroadcastReceiver.java:38)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:4349)
at android.app.ActivityThread.access$2500 (ActivityThread.java:296)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2238)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loop (Looper.java:213)
at android.app.ActivityThread.main (ActivityThread.java:8178)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1101)
aws-exports.js
const awsmobile = {
"aws_project_region": "eu-west-1",
"aws_cognito_identity_pool_id": "xxxxx",
"aws_cognito_region": "eu-west-1",
"aws_user_pools_id": "eu-west-1_B0DDvRpxx",
"aws_user_pools_web_client_id": "xxxxx",
"oauth": {
"domain": "[xxxxxxxxx/)",
"scope": [
"phone",
"email",
"openid",
"profile",
"aws.cognito.signin.user.admin"
],
"redirectSignIn": "Villeo://",
"redirectSignOut": "Villeo://",
"responseType": "code"
},
"federationTarget": "COGNITO_USER_POOLS",
"aws_cognito_username_attributes": [
"EMAIL"
],
"aws_cognito_social_providers": [
"FACEBOOK",
"GOOGLE",
"APPLE"
],
"aws_cognito_signup_attributes": [
"EMAIL"
],
"aws_cognito_mfa_configuration": "OFF",
"aws_cognito_mfa_types": [
"SMS"
],
"aws_cognito_password_protection_settings": {
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": []
},
"aws_cognito_verification_mechanisms": [
"EMAIL"
],
"aws_appsync_graphqlEndpoint": xxxxxxx/graphql",
"aws_appsync_region": "eu-west-1",
"aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS",
"aws_cloud_logic_custom": [
{
"name": "Pinpoint",
"endpoint": "xxxxx/prod",
"region": "eu-west-1"
},
{
"name": "AdminQueries",
"endpoint": xxxxx/prod",
"region": "eu-west-1"
}
],
"aws_user_files_s3_bucket": "xxxx-prod",
"aws_user_files_s3_bucket_region": "eu-west-1",
"aws_mobile_analytics_app_id": "xxxxx",
"aws_mobile_analytics_app_region": "eu-west-1"
};
Manual configuration
No response
Additional configuration
No response
Mobile Device
From google play console :
Huawei HUAWEI P smart 2020 Huawei P20 Huawei Y9 Prime 2019 Samsung Galaxy Note3 (Keep in mind that other users may have not shared crash infos)
Mobile Operating System
Android 5.0, 9 & 10 (Keep in mind that other users may have not shared crash infos)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (5 by maintainers)
The patch works fine for me. Thanks @ChrisLFieldsII. Here is the Java implementation:
Hmm sounds like maybe your
MainActivityisjava?It’s this api though: https://developer.android.com/reference/android/app/Activity#getIntent()
So if you are using java, you might need to change
intenttogetIntent()thats the first thought that comes to my mind, just a difference between
kotlinandjavasyntax as my example iskotlinHere is the patch I am using to make the push notifications module compatible with android 12
Note that the changes in the
RNPushNotificationBroadcastReceiver.javaare useless. Its the changes inRNPushNotificationHelper.javathat matter.I totally forgot to add this… After patching the amplify pushnotification module, I had to then modify my
MainActivityto handle thePendingIntentattached to the notification vianotification.setContentIntent(pendingIntent);Here is what that looks like
The key is
onCreateandonNewIntentto check if anotificationis attached to the intent bundle and if so callhandleNotificationOnIntentwhich was just ripped from what AWS already wrote.