Skip to content

Android 12 support for PendingIntents with the Immutable Flag #377

@brijesh-runkeeper

Description

@brijesh-runkeeper

Hello Iterable team,

I'd like to call out an issue with the Iterable Android SDK when targeting version 31 when processing a push notification in the app.

java.lang.IllegalArgumentException: 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.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
        at com.iterable.iterableapi.IterableNotificationHelper$IterableNotificationHelperImpl.createNotification(IterableNotificationHelper.java:191)
        at com.iterable.iterableapi.IterableNotificationHelper.createNotification(IterableNotificationHelper.java:36)
        at com.iterable.iterableapi.IterableFirebaseMessagingService.handleMessageReceived(IterableFirebaseMessagingService.java:62)

The documentation from Google - https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability

The change should be straightforward in https://github.com/Iterable/iterable-android-sdk/blob/master/iterableapi/src/main/java/com/iterable/iterableapi/IterableNotificationHelper.java#L195. It would essentially involve adding the PendingIntent.FLAG_IMMUTABLE to the flags.

PendingIntent notificationClickedIntent = PendingIntent.getBroadcast(context, notificationBuilder.requestCode,
                    pushContentIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions