Since I upgraded the android api 30 to api 31, the firebase “push” notifications with ionic capacitor stopped working for android 12, they only work for android 11 api 30 or below
It works correctly with the target SDK 30, but you have to update this due to the new requirement of google play
Same problem here, but I confess I’m using quite an old version of Capacitor (2.4.7).
Push Notifications are correctly received if the App is in the foreground (they are received and displayed by the App itself).
But if the App is in the background or closed, the system does not display anything.
Looking inside LogCat I see these two lines that may be relevant (where XXXXXXX was my App package id):
Yes, if you have not upgraded to Capacitor 4, you are unlikely to have much success with various Google service-related plugins when targeting SDK31 on Android. Capacitor 4 is a required update to support this target SDK.
Then, server side, the content of the Push must include the notification object, or it won’t be displayed by the system, something like:
{
"notification":{
"title":"This is the needed title for system display",
"body":"This is the needed body for system display"
},
"data" : {
"custom_app_field1" : "Whatever",
"custom_app_field2" : "Whenever"
}
}
And if “phonegap-plugin-push” or “cordova-plugin-push” were used, they must be removed for the project.
Also, if “jetifier” was used, it must be run again, to clear up of unused jetified classes.
Note however, that directly editing the capacitor.build.gradle file is not the best thing to do, because it’ll be overwritten each time a “cap sync” command is issued!
I tried to add the same two lines in capacitor.build.gradle but then it is generating an error when I try to install it on my mobile. Basically, my build is failing anything else I can try?
I also have same issue as you have can see notifications in console whenever I inspect in android 12 too but nothing appears in the notification tray
I tried your solution but then its showing error while installing build from android studio into my mobile.
Any help will be appreciated.