Reputation: 11
FATAL EXCEPTION: Firebase-FCMService Process: com.petbacker.android, PID: 4405 java.lang.IllegalArgumentException: com.petbacker.android: 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:401) at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:484) at android.app.PendingIntent.getActivity(PendingIntent.java:470) at android.app.PendingIntent.getActivity(PendingIntent.java:434) at com.google.firebase.messaging.zzb.zzf(Unknown Source:68) at com.google.firebase.messaging.zzc.zzas(Unknown Source:34) at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source:59) at com.google.firebase.iid.zzb.run(Unknown Source:2) 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(Unknown Source:6) at java.lang.Thread.run(Thread.java:1012)
App Should not crash on push Notifications in background
Upvotes: 0
Views: 869
Reputation: 580
This Might help you,
Add this in FirebaseService class
try {
//ToDo Update the code for S+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
pendingIntent = PendingIntent.getActivity
(this, 101, intent,
PendingIntent.FLAG_IMMUTABLE| PendingIntent.FLAG_UPDATE_CURRENT);
}
else
{
pendingIntent = PendingIntent.getActivity
(this, 101, intent, PendingIntent.FLAG_ONE_SHOT| PendingIntent.FLAG_UPDATE_CURRENT);
}
} catch (Exception e) {
e.printStackTrace();
}
Upvotes: 1