反应本机 firebase 消息传递点击通知
react native firebase messaging click notification
我收到了发件人的通知,当我点击通知时,应用程序打开了。
但是,通知 return 值不会调用 onMessage()
函数。
从 documentation 开始,函数 getInitialNotification()
是做我需要的。但是当应用程序打开时仍然没有从 onMessage()
中获得任何值。
componentDidMount(){
firebase.messaging().getInitialNotification();
firebase.messaging().onMessage(function(payload) {
console.log("Message received. ", payload);
// ...
});
}
根据documentation、getInitialNotification
returns Promise
,所以你应该这样使用它:
firebase.messaging().getInitialNotification().then( initialMessage => {
console.log("Initial Message: ", initialMessage);
})
https://rnfirebase.io/docs/v3.1.x/messaging/reference/messaging#getInitialNotification
我收到了发件人的通知,当我点击通知时,应用程序打开了。
但是,通知 return 值不会调用 onMessage()
函数。
从 documentation 开始,函数 getInitialNotification()
是做我需要的。但是当应用程序打开时仍然没有从 onMessage()
中获得任何值。
componentDidMount(){
firebase.messaging().getInitialNotification();
firebase.messaging().onMessage(function(payload) {
console.log("Message received. ", payload);
// ...
});
}
根据documentation、getInitialNotification
returns Promise
,所以你应该这样使用它:
firebase.messaging().getInitialNotification().then( initialMessage => {
console.log("Initial Message: ", initialMessage);
})
https://rnfirebase.io/docs/v3.1.x/messaging/reference/messaging#getInitialNotification