-
Notifications
You must be signed in to change notification settings - Fork 764
Description
I am using the latest version of this lib 3.1.1-snapshot.95.
because version 3.1.1 has an issue with the @nullable annotation in one of the files.
My react native version is 0.59.10.
When receiving a push message when the app is in the foreground the PushNotification.java file is also creating an empty notification in the tray. I don't want this, because I handle the notification in code.
On top of that I can't get the notification if the app is started from clicking on a notification when the app is killed/not started.
Can't we remove line 66 of the file PushNotification.java
public void onReceived() throws InvalidNotificationException {
postNotification(null); -> delete this line
notifyReceivedToJS();
}
Or is there a possibility to dismiss the notification direct?
Regarding not receiving the notification from a cold start I suggest using the implementation from parseIntentForRemoteNotification in react-native-firebase 5.x
I created a native component that uses this so i can do run this code in my appliction
/*
* Check if app was opend by a clicking on a push notification. and the app was closed
* No intrested in faillure so no catch
* */
if (IS_IOS) {
void Notifications.getInitialNotification().then(notificationData => {
if (notificationData && notificationData.payload && notificationData.payload.data) {
this.handleNotification(notificationData.payload.data)()
}
})
} else if (IS_ANDROID) {
if (NativeModules.GetPushData && NativeModules.GetPushData.getInitialNotification) {
void NativeModules.GetPushData.getInitialNotification().then((notification: any) => {
if (notification && notification.notification && notification.notification.data) {
this.handleNotification(notification.notification.data)()
}
})
}
}```
I am using react-native-firebase 6 because of crashlytics and the notification lib won't be available. Else I would keep on using react-native-firebase 5.x
Is there a way to fix these issues or am I using the lib wrong?