[🐛] 🔥 onNotificationOpenedApp() not running and getInitialNotification() not providing data when restoring app state from storage on Android #7976
Labels
platform: android
plugin: messaging
FCM only - ( messaging() ) - do not use for Notifications
resolution: needs-repro
This issue could be reproduced or needs a repro provided.
type: bug
New bug report
Issue
Describe your issue here
Hi, we are experiencing a problem where opening the app from a push notification do not provide notification data, or trigger the onNotificationOpenenedApp event when app with app-state is restored from storage on Android. I do not mean from memory.
It happens when the app-state has been stopped and lies in memory then moved to storage after phone runs out of ram by opening other apps etc. When opening a push notification when the app is in this state. The app-state is restored from storage, and the onNotificationOpenenedApp does not trigger and getInitialNotification() gives null for the remoteMessage.
In all other scenarios we have no problems with push notifications, it only happens in this rear scenario.
Project Files
build.gradle
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.22"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.google.gms:google-services:4.4.2")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}
apply plugin: "com.facebook.react.rootproject"
Javascript
// User has permissions or provisional permissions
messaging().onNotificationOpenedApp(async (remoteMessage) => {
console.log('Notification opened app:', remoteMessage);
if (remoteMessage?.data?.url) {
notificationQueue.enqueue({ url: remoteMessage.data.url as string });
}
});
// Handle foreground messages
messaging().onMessage(async (remoteMessage) => {
console.log('Foreground message:', remoteMessage);
});
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
console.log('Doing some handling :)');
});
// Check for notifications that caused the app to open from a terminated state
messaging()
.getInitialNotification()
.then((remoteMessage) => {
console.log('Notification caused app to open from terminated state:', remoteMessage);
if (remoteMessage?.data?.url) {
notificationQueue.enqueue({ url: remoteMessage.data.url as string });
}
});
Click To Expand
package.json
:firebase.json
for react-native-firebase v6:# N/A
iOS
Click To Expand
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:// N/A
android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:AndroidManifest.xml
:Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:20.3.0
Firebase
module(s) you're using that has the issue:e.g. Instance ID
TypeScript
?Y
&4.8.4
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: