-
I having a problem with receiving notification messages. I use cloud function to push data messages to the client and use Notifee to display it. Everything is great, I can send and receive in foreground, background and quit state. // index.js
const backgroundHandler = (message) => {
console.log('Message comes when app is in the background/quit state');
// ... check some condition before deciding to display the message or not
if (!shouldDisplay) return; // suppress the message
notifee.displayNotification({
title: message.data.title,
body: message.data.body
})
}
n12.setBackgroundMessageHandler(backgroundHandler); // App.tsx
const foregroundHandler = (message) => {
console.log('Message comes when app is in the foreground');
}
useEffect(() => {
messaging().onMessage(foregroundHandler);
}, []) Everything is fine, very straightforward. Then one day one of my iphone (iOS 15.5) doesn't show message when the app is in background/quit state anymore. The message did come to the device, but somehow it waits/delays until the app comes into the foreground state. The backgroundHandler should be triggered if a message comes when the app is in background/quit state. But it's never called. When I open the app, the foregroundHandler is triggered right after that. Same code, but the other iphone (iOS 14.7) works fine.
Have you ever had this situation? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
When I test on different phones with different version of iOS I can narrow down
What I can say is that iOS 15.5 alone is not a problem, but also the device. It seems that the message is only delayed on iPhone wth iOS 15.5 AND it's a data message. Notification message is Ok. I've tried changing parameters when sending messages, but it looks like it's a client side problem. |
Beta Was this translation helpful? Give feedback.
-
I found the reason why! It's not the iOS, it's not firebase, it's not the device
The message did come, but if the app is not allowed to refresh itself at the background, the listener is not triggered. The message is delayed until it comes to the foreground. This took me 3 days scratching head crazily. Now when I search with the keyword "firebase messaging background app refresh" I found https://rnfirebase.io/messaging/usage#ios-background-limitation it states very clearly. When I said "one day, it doesn't work anymore". It's because the iPhone must have gone to the Low Power Mode, the Background App Refresh is turned off automatically. How did I miss this out! |
Beta Was this translation helpful? Give feedback.
I found the reason why! It's not the iOS, it's not firebase, it's not the device
The message did come, but if the app is not allowed to refresh itself at the background, the listener is not triggered. The message is delayed until it comes to the foreground.
This took me 3 days scratching head crazily. Now when I search with the keyword "firebase messaging background app refresh" I found https://rnfirebase.io/messaging/usage#ios-background-limitation it states very clearly. When I said "one day, it doesn't work anymore". It's because the iPhone must have gone to the Low Power Mode, the Background App Refresh is…