flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [firebase_messaging] iOS Push Notifications not received when app is terminated using Firebase Data Messages

Open hieulh94 opened this issue 4 years ago • 6 comments

I configured my app to work with FCM Data messages, push notifications are coming when the app is in foreground and background state, BUT NOT if the app is terminated (swipe up from multitasking). API : { "data": { "type": "guide", "id": "07fc127bc9b646df8abe" }, "to": "/topics/guide", "priority": "high", "content_available": true } How can I solve the problem in this situation?

hieulh94 avatar Mar 14 '22 04:03 hieulh94

That looks like a data only message. These messages don't trigger notification alerts. Try adding a title and a body in the notification object.

Petri-Oosthuizen avatar Mar 14 '22 04:03 Petri-Oosthuizen

@HieuHongLe94 If you are swiping away to terminate the app, according to the documentation, you'll need to manually reopen app to start receiving messages again:

See this link for further reference: https://firebase.flutter.dev/docs/messaging/usage#receiving-messages

Closing this for now.

darshankawar avatar Mar 14 '22 12:03 darshankawar

@HieuHongLe94 If you are swiping away to terminate the app, according to the documentation, you'll need to manually reopen app to start receiving messages again:

See this link for further reference: https://firebase.flutter.dev/docs/messaging/usage#receiving-messages

Closing this for now.

Can we handle it when use data only message ?

hieulh94 avatar Mar 14 '22 14:03 hieulh94

That looks like a data only message. These messages don't trigger notification alerts. Try adding a title and a body in the notification object.

Yes. But i want to use data only message :)

hieulh94 avatar Mar 14 '22 14:03 hieulh94

In this case, you might have to use it in conjunction with a package such as flutter_local_notifications to trigger the notifications for you. You should however not rely on background processing to be reliable across platforms. This is one of the issues I'm currently dealing with.

But yeah, as mentioned by @darshankawa, if you terminated the app by swiping up you'll need to manually reopen the app to start receiving messages again.

Petri-Oosthuizen avatar Mar 14 '22 15:03 Petri-Oosthuizen

In this case, you might have to use it in conjunction with a package such as flutter_local_notifications to trigger the notifications for you. You should however not rely on background processing to be reliable across platforms. This is one of the issues I'm currently dealing with.

But yeah, as mentioned by @darshankawa, if you terminated the app by swiping up you'll need to manually reopen the app to start receiving messages again.

Thank you . I will use notification message

hieulh94 avatar Mar 15 '22 02:03 hieulh94