capacitor-community / capacitor-community/fcm

Crash app when receive a notification in background

Open
#151 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
272
Forks
96
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

Open the contributing guide

Research direction

Start by tracing the background notification path through FirebaseMessagingService and the Firebase Messaging dependency shown in the stack trace, version 20.1.2. Verify the Android 31+ PendingIntent requirement in the Capacitor FCM integration and reproduce with the reported setup. Done means a background topic notification no longer crashes on Android 31 and above.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, firebase
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.