Push notifications not work in android 12

I have a notification problem.

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

Has anyone else had this issue ?

1 Like

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):

2023-01-05 18:26:45.847 1602-2091/? I/ActivityManager: Start proc 20461:XXXXXXXX/u0a346 for broadcast {XXXXXXXX/com.google.firebase.iid.FirebaseInstanceIdReceiver}
2023-01-05 18:26:45.939 20461-20476/XXXXXXXXXX V/ActivityThread: scheduleReceiver info = ActivityInfo{862f481 com.google.firebase.iid.FirebaseInstanceIdReceiver} intent = Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1080010 pkg=XXXXXXXXX cmp=XXXXXXXXXX/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) } sync = true hasCode = 153328855

but hothing thereafter…

I believe you need to update to Capacitor 4 in order to support Android 12 (SDK 31) and @capacitor/push-notifications": “^4.0.0”.

1 Like

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.


I know… and I’ll upgrade as soon as possible, but from Capacitor 2 to 4 it’s a big step that I better not to undertake, right now… :blush:

But it seems I have managed to have it work with Capacitor 2…
What I did was adding the following lines inside capacitor.build.gradle:

    implementation 'com.google.firebase:firebase-messaging:23.0.0'
    implementation 'com.google.firebase:firebase-iid:21.1.0'

Then, server side, the content of the Push must include the notification object, or it won’t be displayed by the system, something like:

      "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!

Does anybody know the clean way to do this?

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.

Thank you caipirginka!!

This solution worked for me, i don’t want to upgrade my project to capacitor 4 either (too many changes and time).

Any solution for Cordova…!