-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Receiving Notifications in Android 31+ fails because of PendingIntent Flag in RNPushNotificationHelper #10252
Comments
+1 this is a blocker, following is the error from logcat RNPushNotificationHelper: failed to send push notification |
Hi guys! I have same problem on any Android 12 :( Logs
Dependencies
|
I've rollbacked to previous for me version of React Native — 0.67.4, and it's work fine again. But I'm sad without upgrade React Native versions 🙁 |
Hello everyone, we are aware of this issue, and we have some refactoring work for our push notifications category that we believe will resolve these issues with the newer versions of Android. |
When can we expect this? |
I went through a lot trying to get amplify pushnotification to work w/ android 12. i left my patch on this issue here Once you get past this It will not show in local dev though!!! Beware. |
@delighteckv I'm curious if @ChrisLFieldsII's patch helps you while we are waiting for the refactor of the push notifications category? |
I've implemented a similar patch and it seems to resolve the issue. This seems to have happened after we upgraded to RN 0.68. |
@jim-jigx If that's the case, do you know if Fabric was enabled when upgrading? |
Not to my knowledge. We have newArchEnabled=false in our gradle.properties. I hope that answers your question. |
I also have implemented @ChrisLFieldsII patch to resolve the issue. Great work and thanks for helping out the community!! |
Glad it could help! I just updated the comment i left the patch on to include the updates I made for our projects One requirement that didn't work for us out-of-the-box was deep linking from cold start (the app would just open on home), but the changes I made in our |
Hi @ChrisLFieldsII - Yes mine is MainActivity.java and unfortunately the additonal changes to MainActivity.java actually break our build. I suspect your using Expo whereas we are not. Anyways the main issue I am facing now seems to be more of an intermittent receiving of the PN's at the O/S level but I suspect it might be some AWS limits on the sandboxed Pinpoint applications vs PROD that limit sends per day (they certainly do for emails) so I'm going to carry on testing in PROD as we have some test devices and user accounts I can play with. At first I though it was an Android 9 issue but soon worked out it wasn't as the android 9 emulator did end up receiving some and then on another test an Android 9 physical device also got one (but one only) but certainly right now its VERY intermittent. My only change to your patch was to put back in the conditional check on !isForeground as we have a seperate Appsync in app notification when the app is open What fun this is ;) |
@tannerabread Verified the patch works fine on Android 12(API 31). Thanks for contribution @ChrisLFieldsII |
I tested again on Android 9 device emulator and what I found was that initially no PN came thru so I went and heated up lunch and 5 mins later when I got back they had arrived. Android 12 device emulator seems to either receive them immediately from google servers or process them immediately and send on to app |
Any updates on this issue? We are stuck at the notification part in our app due to this. |
I got app crash when trying to run android file (this came after I installed @aws-amplify/pushnotification) , I get below error code can someone tell me what should I do next Error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl550519623.tmp/base.apk (at Binary XML file line #165): com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present' |
This is whats causing the crash.
Here is a reference to the fix on stackoverflow: https://stackoverflow.com/a/70333589/5434172 In short, you need to add Whether the value is Hope that helps. |
Thank you @ChrisLFieldsII, while we are still working on the root cause of this issue, the docs were updated today (12/9) to show the updates with |
Any update on a fix? |
@LYevhen, I wanted to bring the conversation about Android SDK 31+ back to the issue it is about. It was pointed out to me that the React Native version is not so important and rather it is with Android 31+ that the PendingIntent Flag starts to show up and the patch listed on the other issue starts being necessary. I believe your We do have major updates coming to the Push Notification category (CC @dylan-westbury) but I don't have an exact timeline, just the knowledge that it is currently in development. This update should solve this issue and some others listed in our repo. On top of that, there is also a patch in the works for this specific issue with the PendingIntent flag Thank you all for your patience while we improve this category |
@tannerabread Thank You a lot for Your response. It is first time I have response in this repo, so quick, so valuable. For some reason token was not set to store either. I took it from ReactNative.getToken module, unofficially but it worked for me ( updateEndpoit with sub, token and optOut) |
@cshfang tested with my config fix did not help
|
Hi @LYevhen. How did you incorporate the fix into your app? The fix has so far been merged to our |
@cshfang Maybe I did something wrong but I take a look here |
Ah. The current released version of As we don't have a tag for every commit that gets merged, the options to consume the fix will have to be to wait for a release, patch your local installed version of the module or use a local npm registry like Verdaccio to do a local version bump yourself. |
@cshfang My appologies, I interpreted it wrong. Thanks for details |
This fix is released! I tested it on my project and it seems to be working as expected @LYevhen can you try |
@tannerabread I've reverted all git patches, changes to MainActivity.java, removed all node modules, updated package.json with mentioned versions 5.0.14, successfully received push notification on my android device. |
Thank you for testing it so quickly @LYevhen! I will close this now but if anyone runs into this problem and the fix in 5.0.14 doesn't work, comment here so we can investigate further |
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Push Notifications
Amplify Categories
notifications
Environment information
Device: Samsung Galaxy S21
Android 12
TargetSdk 31
Describe the bug
If I receive a notification in Android 12 (version 31 and above) while the app is in the background I get an exception and the app fails to display the notification.
Expected behavior
Pinpoint notifications work fine on Android 12.
Reproduction steps
Followed Setup Instructions https://docs.amplify.aws/lib/push-notifications/getting-started/q/platform/js/
Attempted to send a new notification with the pinpoint test-messaging service
Additional information and screenshots
Works when Flag of PendingIntent in RNPushNotificationHelper is set to FLAG_IMMUTABLE or FLAG_MUTABLE
aws-amplify/aws-sdk-android#2729
The text was updated successfully, but these errors were encountered: