在一个事件中反应在后台触发的本机 firebase 多个通知
React native firebase multiple notification triggered in background in one event
一次事件触发两次后台通知,不应该发生,
我无法检测到问题?我正在使用带有 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()
}
}, [])
我同时使用了 onForeground() 通知和 onBackground() 通知,
当我删除 onBackground() 通知时,onForeground 方法也在后台触发,所以我在一个事件中收到了两个通知......情况不应该是这样,但现在似乎可以工作......
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');
}
//
//This is for receiving notification onForeground
//
const unsubscribe = messaging().onMessage(onMessageReceivedFore);
return () => {
console.log('component unmount');
onNotificationInteraction()
unsubscribe()
}
}, [])
一次事件触发两次后台通知,不应该发生, 我无法检测到问题?我正在使用带有 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()
}
}, [])
我同时使用了 onForeground() 通知和 onBackground() 通知, 当我删除 onBackground() 通知时,onForeground 方法也在后台触发,所以我在一个事件中收到了两个通知......情况不应该是这样,但现在似乎可以工作......
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');
}
//
//This is for receiving notification onForeground
//
const unsubscribe = messaging().onMessage(onMessageReceivedFore);
return () => {
console.log('component unmount');
onNotificationInteraction()
unsubscribe()
}
}, [])