iterable-android-sdk icon indicating copy to clipboard operation
iterable-android-sdk copied to clipboard

[bug] android 12 crash PendingIntent FLAG_MUTABLE flag

Open gturedi opened this issue 2 years ago • 6 comments

if i set app target level to 31. iterable sdk crashed the app when showing notification on android 12 devices. here logs:

Fatal Exception: java.lang.IllegalArgumentException com.popcornvan.app: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. android.app.PendingIntent.checkFlags (PendingIntent.java:382) android.app.PendingIntent.getBroadcast (PendingIntent.java:660) com.iterable.iterableapi.IterableNotificationHelper$IterableNotificationHelperImpl.createNotification (IterableNotificationHelper.java:195) com.iterable.iterableapi.IterableNotificationHelper.createNotification (IterableNotificationHelper.java:37) com.iterable.iterableapi.IterableFirebaseMessagingService.handleMessageReceived (IterableFirebaseMessagingService.java:62) com.popcornvan.orderingapp.util.firebase.PopcornFirebaseMessagingService.onMessageReceived (PopcornFirebaseMessagingService.kt:14) com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage (com.google.firebase:firebase-messaging@@22.0.0:13)

it is for pending intent, it should like below:

val pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { PendingIntent.getActivity(this, 0, activityIntent, PendingIntent.FLAG_IMMUTABLE) } else { PendingIntent.getActivity(this, 0, activityIntent, PendingIntent.FLAG_UPDATE_CURRENT) }

gturedi avatar Feb 14 '22 09:02 gturedi