# Push notifications not work in android 12

**URL:** <https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025>\
**Category:** Capacitor\
**Created:** [January 5, 2023, 2:51am UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025 "2023-01-05T02:51:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jperez25](https://avatars.discourse-cdn.com/v4/letter/j/a4c791/32.png) [@jperez25](https://forum.ionicframework.com/u/jperez25)\
**Post date:** [January 5, 2023, 2:51am UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025/1 "2023-01-05T02:51:29Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![mikrochipkid](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mikrochipkid/32/116956_2.png) [@mikrochipkid](https://forum.ionicframework.com/u/mikrochipkid)\
**Post date:** [January 5, 2023, 3:22am UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025/2 "2023-01-05T03:22:20Z")

</div>

> **[How do I ask a good question? - Help Center](https://stackoverflow.com/help/how-to-ask)**
>
> Stack Overflow | The World’s Largest Online Community for Developers

---

<div class="post-metadata">

**Author:** ![caipirginka](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@caipirginka](https://forum.ionicframework.com/u/caipirginka)\
**Post date:** [January 5, 2023, 5:45pm UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025/3 "2023-01-05T17:45:52Z")

</div>

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

```auto
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…

---

<div class="post-metadata">

**Author:** ![twestrick](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/twestrick/32/136131_2.png) [@twestrick](https://forum.ionicframework.com/u/twestrick)\
**Post date:** [January 5, 2023, 7:57pm UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025/4 "2023-01-05T19:57:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dallas](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dallas/32/141875_2.png) [@dallas](https://forum.ionicframework.com/u/dallas)\
**Post date:** [January 6, 2023, 4:03pm UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025/5 "2023-01-06T16:03:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![caipirginka](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@caipirginka](https://forum.ionicframework.com/u/caipirginka)\
**Post date:** [January 9, 2023, 4:09pm UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025/6 "2023-01-09T16:09:53Z")

</div>

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… 😊

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

```auto
    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:

```auto
{
    "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.

---

<div class="post-metadata">

**Author:** ![caipirginka](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@caipirginka](https://forum.ionicframework.com/u/caipirginka)\
**Post date:** [January 9, 2023, 4:20pm UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025/7 "2023-01-09T16:20:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Vishva\_Cipherehx](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vishva\_Cipherehx](https://forum.ionicframework.com/u/Vishva_Cipherehx)\
**Post date:** [January 10, 2023, 5:54am UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025/8 "2023-01-10T05:54:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![charly901](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@charly901](https://forum.ionicframework.com/u/charly901)\
**Post date:** [February 14, 2023, 11:24am UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025/9 "2023-02-14T11:24:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shaileshpendams0](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/shaileshpendams0/32/144577_2.png) [@shaileshpendams0](https://forum.ionicframework.com/u/shaileshpendams0)\
**Post date:** [April 4, 2023, 9:59am UTC](https://forum.ionicframework.com/t/push-notifications-not-work-in-android-12/230025/10 "2023-04-04T09:59:37Z")

</div>

> [@jperez25](#):
>
> 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

Any solution for Cordova…!
