chemerisuk / cordova-plugin-firebase-messaging

Cordova plugin for Firebase Cloud Messaging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pending Intents - Android@8 - API Level 31

florgb02 opened this issue · comments

@chemerisuk

This plugin was integrated a while ago on IONIC3+Cordova project. And recently we upgraded from API LEVEL 30 to 31

Unfortunately I am getting the PendingIntent FLAG_IMMUTABLE error required which is making the app crash on push notification sent and app is Background. Foreground push notification is working as expected.

Error Android:
... stack trace**:java.lang.IllegalArgumentException:** app: **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.zzf.run(Unknown Source:4)
    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)

Information:
IONIC 3
@ionic-native/firebase-messaging: "^4.20.0"
cordova-plugin-firebase-messaging: "4.4.2"
"cordova-plugin-firebase-messaging": {
"FIREBASE_MESSAGING_VERSION": "20.1.+",
"ANDROIDX_CORE_VERSION": "1.2.+"
},

Environment Details:
Ionic:
ionic (Ionic CLI) : 4.2.1
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0

Cordova:
cordova (Cordova CLI) : 10.0.0
Cordova Platforms : android 8.1.0

System:
ios-deploy : 1.12.0
ios-sim : 8.0.2
NodeJS : v10.16.3
npm : 6.9.0
OS : macOS
Xcode : Xcode 14.1 Build

Thanks

@florgb02 try to upgrade to the latest version of the plugin. I don't think v4.4.2 supports android 30-31.

Thanks @chemerisuk unfortunately we can't upgrade at the moment but I was able to patch the plugin to target firebase.messaging version 23.0.0 and support for :firebase-iid:21.1.0 Both contain fixes to support PendingIntent FLAG_MUTABLE and FLAG_IMMUTABLE
Adding:
<framework src="com.google.firebase:firebase-messaging:23.0.0" />
<framework src="com.google.firebase:firebase-iid:21.1.0" />
Thanks