react-native-push-notification
react-native-push-notification copied to clipboard
Opening app from remote notification is blocked on Android 12 targetSdk=31
Bug
Everything is working as expected on iOS and Android 6 to 11. For Android 12 (targetSdk=31) the notification is received if the app is in foreground. If the app is in background, the notification is displayed in notification center, but when i tap on the notification the app is not opened. I can see in the logs that it's blocked due to the trampoline
E/NotificationService: Indirect notification activity start (trampoline) from my.app.dev blocked
Should this issue be already fixed with this PR?
Environment info
Android: 12 TargetSdk: 31 Library version: 8.1.1
Hi, I have the same issue. The problem when app in background. Try to do some thing like this post: https://developer.android.com/training/notify-user/navigation but not help. In my case when click on notification it will open SplashActivity.
I want to provide more info about issue: I can see that when notification not work the dump logs: 05-25 17:20:44.867 D NotificationClicker: CLICK 0|se.precio.news|0|FCM-Notification:10122480|10305 (channel=OF_FEED) 05-25 17:20:44.867 D NotifActivityStarter: (1/4) onNotificationClicked: 0|se.precio.news|0|FCM-Notification:10122480|10305 05-25 17:20:44.867 D NotifActivityStarter: (2/4) handleNotificationClickAfterKeyguardDismissed: 0|se.precio.news|0|FCM-Notification:10122480|10305 05-25 17:20:44.867 D NotifActivityStarter: (3/4) handleNotificationClickAfterPanelCollapsed: 0|se.precio.news|0|FCM-Notification:10122480|10305 05-25 17:20:44.868 I NotifActivityStarter: (4/4) Starting Intent { act=com.google.firebase.MESSAGING_EVENT cmp=se.precio.news/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) } for notification 0|se.precio.news|0|FCM-Notification:10122480|10305
When it work: 05-25 16:29:00.925 D NotificationClicker: CLICK 0|se.precio.news|0|FCM-Notification:7159152|10305 (channel=OF_FEED) 05-25 16:29:00.925 D NotifActivityStarter: (1/4) onNotificationClicked: 0|se.precio.news|0|FCM-Notification:7159152|10305 05-25 16:29:00.927 D NotifActivityStarter: (2/4) handleNotificationClickAfterKeyguardDismissed: 0|se.precio.news|0|FCM-Notification:7159152|10305 05-25 16:29:00.927 D NotifActivityStarter: (3/4) handleNotificationClickAfterPanelCollapsed: 0|se.precio.news|0|FCM-Notification:7159152|10305 05-25 16:29:00.928 I NotifActivityStarter: (4/4) Starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x14000000 pkg=se.precio.news cmp=se.precio.news/.SplashActivity (has extras) } for notification 0|se.precio.news|0|FCM-Notification:7159152|10305
we can see that in case intent is com.google.firebase.MESSAGING_EVENT notification open will be block
I able found root cause. As what I test and debug. When app is not running in background then firebase-messaging is handle the remote notification. and currently react-native-push-notification version 8.1.1 is using old version of 21.1.0 which have issue with Android 12 check this github issue:https://github.com/firebase/firebase-android-sdk/issues/3423
So I have a workaround for this issue that install new version of firebase-messaging in my app build.gradle: implementation "com.google.firebase:firebase-messaging:23.0.5"
now when app not running in background. when click on notification it can open app. Cheer
@Dallas62 Can we try update newer version of com.google.firebase:firebase-messaging to resolve this issue?
Hi, does anyone find solution different than modifying build.gradle
file as stated above?
Or does Android 12 restricted opening Apps from notifications at all?
You can set the version used by react-native-push-notification directly like this :
in android/gradle.properties
firebaseMessagingVersion=23.0.5
Having the same issue with Android 11+, Any solution ?
https://github.com/zo0r/react-native-push-notification#state-of-the-repository
firebaseMessagingVersion=23.0.5
@Ddv0623 Can you show us how to update this? I added the following to my /android/app/build.gradle:
implementation "com.google.firebase:firebase-messaging:23.0.5"
But the app is not able to build after that.
ok. I found the solution. For everyone who is getting error when making the android build after updating the firebase messaging to 23.0.5, please check this:
https://github.com/firebase/firebase-android-sdk/issues/4206#issue-1409911151
I added the following to my "android/app/build.gradle" in the dependencies section:
implementation platform('com.google.firebase:firebase-bom:31.0.0')
implementation 'com.google.firebase:firebase-functions'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-iid:21.1.0'
And also updated the firebasemessageingVersion to 23.0.5 in my "android/build.gradle"