[Android] getInitialNotification not working

See original GitHub issue

I have installed the latest version of this package. I have made the link manually on Android according to the guide.

Everything works: NotificationsAndroid.setNotificationOpenedListener, NotificationsAndroid.setRegistrationTokenUpdateListener, etc. and in iOS also everything is fine.

But PendingNotifications.getInitialNotification() always return N/A (false), so I can’t get the payload when a notification is openen and the app was closed.

I use:

"react-native": "0.60.5",
"react-native-navigation": "^3.1.2",
"react-native-notifications": "^2.1.0"

Any ideas what could be wrong?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
jakubkocicommented, Oct 17, 2019

@CristianOspina What service are you using to test it? I had the same problem because I tried to send a notification directly from Firebase console. But this perhaps sends only Notification Message and you have to send Data Message to notification be passed into onMessageReceived method (see https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages).

If I send following HTTP POST request to https://fcm.googleapis.com/fcm/send (via curl or Postman for example) it works for both, the app on the background and killed app:

Headers:

Content-Type: application/json
Authorization: key=<SERVER_KEY>

Body:

{
 "to" : "DEVICE_TOKEN",
 "data" : {
     "body" : "Body of Your Notification in Data",
     "title": "Title of Your Notification in Title",
     "key_1" : "Value for key_1",
     "key_2" : "Value for key_2"
 }
}
0reactions
uday5162commented, Nov 22, 2019

I tried deleting the notification node which is working fine. But unable to get notification image after removing. any idea?

Read more comments on GitHub >

github_iconTop Results From Across the Web

getInitialNotification not working · Issue #3964 - GitHub
Issue The messaging().onNotificationOpenedApp works perfectly fine, when the app is open but is in the background. The messaging().getInitialNotification() ...
Read more >
firebase.messaging().getInitialNotification() does not work on ...
My problem was resolved by using API from 3d-party library such react-native-push-notification instead of firebase.messaging().
Read more >
messaging | React Native Firebase
getInitialNotification. </>. When a notification from FCM has triggered the application to open from a quit state, this method will return a RemoteMessage ......
Read more >
getInitialNotification - Notifee
This API can be used to fetch which notification & press action has caused the application to open. The call returns a null...
Read more >
[Resolve]-react-native-firebase: onNotificationOpenedApp and ...
Coding example for the question react-native-firebase: onNotificationOpenedApp and getInitialNotification not working on iOS.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found