Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react native firebase messaging click notification

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);
      // ...
    });
  }
like image 818
FeelRightz Avatar asked Jun 30 '26 05:06

FeelRightz


1 Answers

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

like image 101
Ivan Chernykh Avatar answered Jul 02 '26 17:07

Ivan Chernykh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!