capacitor-community / fcm

Enable Firebase Cloud Messaging for Capacitor apps
https://capacitor.ionicframework.com/docs/
MIT License
238 stars 83 forks source link

Crash app when receive a notification in background #151

Open TalesMattos opened 10 months ago

TalesMattos commented 10 months ago

When I subscribe to a topic and then the app goes to the background, when a new notification is received, the app crashes. I am using Ionic 4 with Capacitor v2 and plugin version 1.1.2 (the latest for Capacitor 2) on Android 13.

see the log when the app crashes:

ERROR: **FATAL EXCEPTION: Firebase-CapacitorFirebaseMessagingService Process: br.com.procergs.estudante, PID: 17542 java.lang.IllegalArgumentException: br.com.procergs.estudante: 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:404) at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:487) at android.app.PendingIntent.getActivity(PendingIntent.java:473) at android.app.PendingIntent.getActivity(PendingIntent.java:437) at com.google.firebase.messaging.zzb.zza(com.google.firebase:firebase-messaging@@20.1.2:62) at com.google.firebase.messaging.zzd.zza(com.google.firebase:firebase-messaging@@20.1.2:33) at com.google.firebase.messaging.FirebaseMessagingService.zzc(com.google.firebase:firebase-messaging@@20.1.2:70) at com.google.firebase.messaging.zze.run(com.google.firebase:firebase-messaging@@20.1.2: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)

Could you guys fix it to work on Android 31 and above? Thanks!