Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] getInitialNotification not working #378

Closed
cospin opened this issue Sep 15, 2019 · 8 comments
Closed

[Android] getInitialNotification not working #378

cospin opened this issue Sep 15, 2019 · 8 comments
Assignees
Labels

Comments

@cospin
Copy link

cospin commented Sep 15, 2019

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?

@cospin
Copy link
Author

cospin commented Sep 15, 2019

The workaround in #326 (comment) works but only when the app is killed. If the app is in background I still can't get the notification.

@yogevbd yogevbd self-assigned this Sep 22, 2019
@yogevbd yogevbd added the bug label Sep 22, 2019
@yogevbd
Copy link
Collaborator

yogevbd commented Sep 26, 2019

Can't reproduce it in our example project and it also doesn't reproduce in our production app. can you elaborate? maybe it's something with the payload itself?

@jakubkoci
Copy link

@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"
 }
}

@rgommezz
Copy link

Can confirm what @jakubkoci stated.

PendingNotifications.getInitialNotification() works as expected when sending a test push notification through a HTTP POST request instead of the firebase console.

@cospin
Copy link
Author

cospin commented Nov 7, 2019

Right. It works now. Sorry for the delay and thank you!

@cospin cospin closed this as completed Nov 7, 2019
@itsmelion
Copy link

itsmelion commented Nov 12, 2019

Thanks @jakubkoci , helped alot..

Any idea how to deal with this in server (Admin SDK) environment ?
cuz my current is giving me undefined notification.

sendMulticast({
  notification: { ... }
  data: { ... }
  android: { notification, data }
  // or anything else
})

@itsmelion
Copy link

Ok, got it.
I just had to delete the notification nodes

@uday5162
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants