Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Exception java.lang.IllegalArgumentException: com.companyname.*: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. #707

@anji22

Description

@anji22

Hi ,

We have upgraded the Android API Level 30 to API Level 31 to support the Android 12 Version in Xamarin Project.
SDK Versions:
Xamarin Forms:5.0.0.2401
Xamarin.Firebase.Messaging:71.1740
Xamarin.Android SDK-13.0.0

In the production we are getting the below issue even we add the Mutable FLAG'S.

Exception java.lang.IllegalArgumentException: com.companyname.*: 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.getActivityAsUser (PendingIntent.java:464)
at android.app.PendingIntent.getActivity (PendingIntent.java:444)
at android.app.PendingIntent.getActivity (PendingIntent.java:408)
at com.google.firebase.messaging.zza.zzh
at com.google.firebase.messaging.FirebaseMessagingService.zzd
at com.google.firebase.iid.zzg.run
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
at com.google.android.gms.common.util.concurrent.zza.run (com.google.android.gms:play-services-basement@@17.6.0:2)
at java.lang.Thread.run (Thread.java:1012)

we added the FLAG_IMMUTABLE for our PendingIntents see below

if (Build.VERSION.SdkInt >= BuildVersionCodes.S)
{

                pendingIntent = PendingIntent.GetActivity(CrossCurrentActivity.Current.AppContext,
                                                         FormsActivity.NOTIFICATION_INTENT_ID,
                                                         intent,
                                                         PendingIntentFlags.Immutable);
            }
            else
            {
              
                pendingIntent = PendingIntent.GetActivity(CrossCurrentActivity.Current.AppContext,
                                                         FormsActivity.NOTIFICATION_INTENT_ID,
                                                         intent,
                                                         PendingIntentFlags.OneShot);
            }

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