capacitor-community / fcm

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

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent #108

Closed kyleabens closed 1 year ago

kyleabens commented 2 years ago

Describe the bug I'm able to obtain the token no problem but when a notification is triggered I get the following error in Android Simulator and no push notification is presented on the device. This is an issue with Android 12.

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent

To Reproduce Steps to reproduce the behavior:

  1. Open an app running this plugin on an Android 12 device
  2. Attempt to send a firebase cloud message using the token obtained to the device

Expected behavior To receive the push notification on the device when the app is closed

Smartphone (please complete the following information):

kyleabens commented 2 years ago

For those that come across this issue, I fixed this in my Ionic Capacitor app by doing the following:

Open android > variables.gradle and change firebaseMessagingVersion to 23.0.0

Then because I also use @capacitor/push-notifications plugin I had to add implementation "com.google.firebase:firebase-iid:21.1.0" to the dependencies in node_modules > @capacitor > push-notifications > android > build.gradle

crossan007 commented 1 year ago

See also https://github.com/ionic-team/capacitor-plugins/issues/1225

stewones commented 1 year ago

reopening cause maybe it's better to upgrade here too. is anyone interested in sending a PR?

crossan007 commented 1 year ago

Is the "upgrade" here as simple as incrementing the version number? Or will there likely be other changes required?

I haven't delved much into the details of how Capacitor plugins actually work (I've only been using them - gratefully)

stewones commented 1 year ago

Is the "upgrade" here as simple as incrementing the version number? Or will there likely be other changes required?

I haven't delved much into the details of how Capacitor plugins actually work (I've only been using them - gratefully)

Yeah I think so. We need to just increment and test the plugin to make sure nothing breaks.