【发布时间】:2021-02-17 07:40:31
【问题描述】:
后台通知在一个事件中触发两次,不应该发生, 我无法检测到问题?我正在使用带有notifee的react native firebase进行通知..! 这是 useEffect 代码,我在其中取消订阅前台通知侦听器。
useEffect(() => {
networkCall()
fetchingUserData().then(() => {
setIsLoading(false)
})
//
// This is a function for receiving the notification message and displaying notification
//
async function onMessageReceivedFore(message: any) {
onDisplayNotification(message);
console.log('message received Foreground');
}
async function onMessageReceivedBack(message: any) {
onDisplayNotification(message);
console.log('message received Background');
}
//
//This is for receiving notification onForeground
//
const unsubscribe = messaging().onMessage(onMessageReceivedFore);
//
//This is for receiving notification on background
//
messaging().setBackgroundMessageHandler(onMessageReceivedBack);
return () => {
console.log('component unmount');
onNotificationInteraction()
unsubscribe()
}
}, [])
【问题讨论】:
-
从 firebase 触发时您会收到两个通知?
-
从 firebase 我得到了一个,但我猜它在我的代码中,这导致显示两个通知,我猜它是监听器的东西
-
打开你的AndroidManifest文件并告诉我
com.dieam.reactnativepushnotification.notification_foreground元数据的值 -
我的清单中没有这样的标签
-
您使用哪个库进行推送通知?
标签: android react-native firebase-cloud-messaging react-native-firebase