question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Receiving Notifications in Android 31+ fails because of PendingIntent Flag in RNPushNotificationHelper

See original GitHub issue

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.

08-23 10:08:55.709 13341 13341 I RNPushNotificationHelper: sendNotification: Intent { cmp=com.aurora_beta/com.amazonaws.amplify.pushnotification.modules.RNPushNotificationBroadcastReceiver (has extras) }

08-23 10:08:55.713 13341 13341 E RNPushNotificationHelper: java.lang.IllegalArgumentException: com.aurora_beta: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

Expected behavior

Pinpoint notifications work fine on Android 12.

Reproduction steps

Additional information and screenshots

Works when Flag of PendingIntent in RNPushNotificationHelper is set to FLAG_IMMUTABLE or FLAG_MUTABLE https://github.com/aws-amplify/aws-sdk-android/pull/2729

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:19 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
delighteckvcommented, Oct 21, 2022

@tannerabread Verified the patch works fine on Android 12(API 31).

Thanks for contribution @ChrisLFieldsII

2reactions
markl-vespercommented, Oct 20, 2022

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 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve "Missing PendingIntent mutability flag" lint ...
I tried this using -alpha04 and still receiving the error. I only have 1 PendingIntent for my application and not able move forward...
Read more >
PendingIntent - Android Developers
Flag indicating that if the described PendingIntent already exists, ... so the PendingIntent you receive from an application could actually be one it ......
Read more >
Push notifications causing a crash when targeting Android API ...
I am using the latest Backendless SDK v6.3.4 and targeting Android SDK 31. When the device receives a push notification message the ...
Read more >
Android 12 PendingIntent Crash Error : r/cn1 - Reddit
for app in background to receive push notification in android 12 without ... Follow steps to build for SDK 31 and replace your...
Read more >
Android 12, PendingIntent Mutability, and Geofences
Apps that target Android 12 (SDK31) must now specify a mutability flag for any pending intents. The documentation and the errors in Android...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found