Open kotran88 opened 1 year ago
I am having a similar issue. Notifications only show up in the foreground.
As a matter of fact, for me (running android 13 on samsung S21 FE 5G), if the app is in the background and a push arrives, the app crashes!
Hopefully somebody can help with this...
I've been running into the same issue, and I've identified the cause. Testing the receipt of push notifications using an emulator running the app, I see this fatal error:
FATAL EXCEPTION: Firebase-Messaging-Intent-Handle
Process: com.my-workplace.MyAppIdentifier, PID: 8789
java.lang.IllegalArgumentException: com.tnsos.GoVoteTN: 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.
Doing some further research, this may be caused by specifying an outdated version of the FCM library as part of the preferences when adding the plugin, but so far my attempts to update it have met with other errors. I'll continue to add information as I go.
@thepsion5 @dimitriscsd @kotran88 This fixed it for me https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated/issues/293#issuecomment-1377487961
As a matter of fact, for me (running android 13 on samsung S21 FE 5G), if the app is in the background and a push arrives, the app crashes!
We have exactly the same issue. Notifications work fine on older Android versions but causing the app to crash on Android 12, 13 (https://github.com/freescout-helpdesk/freescout/issues/2718)
@thepsion5 Have you found the solution? This solution https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated/issues/293#issuecomment-1377487961 does not work for us - still no push notifications on Android 13.
The solution definitely works.
After replacing the plugins, have you deleted your platforms and plugins folders and then built again? That needs to happen for the new plugin files to be placed in the platform.
Android platform is removed and re-added. Still push notifications work on Android 9 phone but don't work on Android 13 (notifications are allowed for the app in the phone settings).
cordova plugin remove cordova-plugin-fcm-with-dependecy-updated cordova plugin add https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated#v6.3.1 --variable ANDROID_DEFAULT_NOTIFICATION_ICON="@mipmap/ic_launcher" --variable ANDROID_FCM_VERSION="23.0.0" --variable ANDROID_FIREBASE_BOM_VERSION="29.0.1" --variable ANDROID_GOOGLE_SERVICES_VERSION="4.3.4" --variable ANDROID_GRADLE_TOOLS_VERSION="4.1.0" --variable IOS_FIREBASE_MESSAGING_VERSION="~> 7.4.0" cordova platform remove android cordova platform add android@8.1.0
Excerpt from config.xml:
<platform name="android" spec="~8.1.0">
<allow-intent href="market:*" />
<preference name="android-minSdkVersion" value="19" />
<preference name="android-targetSdkVersion" value="31" />
</platform>
<engine name="android" spec="^8.1.0" />
<plugin name="cordova-plugin-fcm-with-dependecy-updated" spec="6.3.1">
<variable name="ANDROID_DEFAULT_NOTIFICATION_ICON" value="@mipmap/ic_launcher" />
<variable name="ANDROID_FCM_VERSION" value="23.0.0" />
<variable name="ANDROID_FIREBASE_BOM_VERSION" value="29.0.1" />
<variable name="ANDROID_GOOGLE_SERVICES_VERSION" value="4.3.4" />
<variable name="ANDROID_GRADLE_TOOLS_VERSION" value="4.1.0" />
<variable name="IOS_FIREBASE_MESSAGING_VERSION" value="~> 7.4.0" />
<variable name="FCM_CORE_VERSION" value="16.0.9" />
<variable name="FCM_VERSION" value="18.0.0" />
<variable name="GRADLE_TOOLS_VERSION" value="3.5.0" />
<variable name="GOOGLE_SERVICES_VERSION" value="4.2.0" />
</plugin>
Android platform is removed and re-added. Still push notifications work on Android 9 phone but don't work on Android 13 (notifications are allowed for the app in the phone settings).
cordova plugin remove cordova-plugin-fcm-with-dependecy-updated cordova plugin add https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated#v6.3.1 --variable ANDROID_DEFAULT_NOTIFICATION_ICON="@mipmap/ic_launcher" --variable ANDROID_FCM_VERSION="23.0.0" --variable ANDROID_FIREBASE_BOM_VERSION="29.0.1" --variable ANDROID_GOOGLE_SERVICES_VERSION="4.3.4" --variable ANDROID_GRADLE_TOOLS_VERSION="4.1.0" --variable IOS_FIREBASE_MESSAGING_VERSION="~> 7.4.0" cordova platform remove android cordova platform add android@8.1.0
Excerpt from config.xml:
<platform name="android" spec="~8.1.0"> <allow-intent href="market:*" /> <preference name="android-minSdkVersion" value="19" /> <preference name="android-targetSdkVersion" value="31" /> </platform> <engine name="android" spec="^8.1.0" /> <plugin name="cordova-plugin-fcm-with-dependecy-updated" spec="6.3.1"> <variable name="ANDROID_DEFAULT_NOTIFICATION_ICON" value="@mipmap/ic_launcher" /> <variable name="ANDROID_FCM_VERSION" value="23.0.0" /> <variable name="ANDROID_FIREBASE_BOM_VERSION" value="29.0.1" /> <variable name="ANDROID_GOOGLE_SERVICES_VERSION" value="4.3.4" /> <variable name="ANDROID_GRADLE_TOOLS_VERSION" value="4.1.0" /> <variable name="IOS_FIREBASE_MESSAGING_VERSION" value="~> 7.4.0" /> <variable name="FCM_CORE_VERSION" value="16.0.9" /> <variable name="FCM_VERSION" value="18.0.0" /> <variable name="GRADLE_TOOLS_VERSION" value="3.5.0" /> <variable name="GOOGLE_SERVICES_VERSION" value="4.2.0" /> </plugin>
The commands above are not correct. You are removing the plugin, then re-adding the same one, instead of the fork.
I am providing again the commands that will install the fork with the fix. Note that after "github.com" on the url, the username is different:
cordova plugin remove cordova-plugin-fcm-with-dependecy-updated
cordova plugin add https://github.com/marutifh/cordova-plugin-fcm-with-dependecy-updated --variable ANDROID_DEFAULT_NOTIFICATION_ICON="@mipmap/ic_launcher" --variable ANDROID_FCM_VERSION="23.0.0" --variable ANDROID_FIREBASE_BOM_VERSION="29.0.1" --variable ANDROID_GOOGLE_SERVICES_VERSION="4.3.4" --variable ANDROID_GRADLE_TOOLS_VERSION="4.1.0" --variable IOS_FIREBASE_MESSAGING_VERSION="~> 7.4.0"
Thanks. Now we are getting the following error when doing cordova build android --prod
:
FCMPlugin: Support for Gradle v4 or lower is deprecated. Please upgrade to a newer version.
It comes from here https://github.com/marutifh/cordova-plugin-fcm-with-dependecy-updated/blob/master/src/android/FCMPlugin.gradle#L100 and thrown because in our config.xml
we have ANDROID_GRADLE_TOOLS_VERSION 4.1.0:
<variable name="ANDROID_GRADLE_TOOLS_VERSION" value="4.1.0" />
Not sure about that one. Depends on your setup.
What I do know is, the configuration for this plugin (and most plugins for that matter) should now reside in package.json and not in config.xml
Cordova switched away from putting that stuff in config.xml quite a while ago. I would remove that whole
For reference, my package.json, in terms of this plugin looks like this:
"cordova": {
"plugins": {
"cordova-plugin-fcm-with-dependecy-updated": {
"ANDROID_DEFAULT_NOTIFICATION_ICON": "@mipmap/ic_launcher",
"ANDROID_FCM_VERSION": "23.0.0",
"ANDROID_FIREBASE_BOM_VERSION": "29.0.1",
"ANDROID_GOOGLE_SERVICES_VERSION": "4.3.4",
"ANDROID_GRADLE_TOOLS_VERSION": "4.1.0",
"IOS_FIREBASE_MESSAGING_VERSION": "~> 7.4.0"
}
},
"platforms": [
"android",
"ios"
]
}
That message about gradle might just be a warning. Is the build finishing or is it failing?
Build is failing:
> Configure project :app
FCMPlugin: Support for Gradle v4 or lower is deprecated. Please upgrade to a newer version.
BUILD FAILED in 5s
/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:processDebugGoogleServices'.
> Cannot create a proxy class for abstract class 'GoogleServicesTask'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Can you please share your versions:
cordova -v
)cordova platform version android
)/platforms/android/gradlew -v
)npm -v
)nodejs -v
)Here is what we have:
After updating nodejs, cordova-android and cordova to newer versions the build succeeded and push notifications are working now on Android 13.
marutifh
After updating nodejs, cordova-android and cordova to newer versions the build succeeded and push notifications are working now on Android 13.
Hi bro would you explain how did you fix your issue?
I tried this but it does not work
on config.xml
<preference name="android-targetSdkVersion" value="31" />
I used it with value 30 and notificiation work find! but changing it to 31, then rm android and add androoid@10, then it is not fired.
on package.json
ionic info