Reputation: 2999
I received the notification from the sender, when I click the notification, app opened.
However, the notification return value does not call to the onMessage()
function.
From the documentation , function getInitialNotification()
is do what I need. But still not get any value from onMessage()
when app opened.
componentDidMount(){
firebase.messaging().getInitialNotification();
firebase.messaging().onMessage(function(payload) {
console.log("Message received. ", payload);
// ...
});
}
Upvotes: 3
Views: 8734
Reputation: 42196
As per documentation, getInitialNotification
returns Promise
, so you should use it like this:
firebase.messaging().getInitialNotification().then( initialMessage => {
console.log("Initial Message: ", initialMessage);
})
https://rnfirebase.io/docs/v3.1.x/messaging/reference/messaging#getInitialNotification
Upvotes: 1