0
votes

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).

As far as I know, if you are using the Data messages you will be in charge of handling the received message and present a notification to the user. Otherwise, if you are using Notification Messages, FCM is handling the message for you and directly displays a notification if the app is in background/closed.

In my app I must use Data messages and therefore have problems with push notifications when app is killed.

From the answers of this post IOS data notifications with FCM, Data messages can't be received in iOS if the app is killed.

I did the following test: I sent a Notification message (instead of Data message) from Firebase Console and the push notification WAS showing up even if the app was closed.

How can I solve the problem in this situation?

1
Have you got the right answer? I have the problem that I receive the notification when the app is active, but nothing when it is terminated. How can I force my app to receive the notifications when the app is killed?Endre Olah
Use the Notification Extension Service offered by Xcode, mate. That will solve the problem.Daniel Z.
Thanks, it works now also when the app is terminated. Super. :)Endre Olah
Glad to help you, @EndreOlah. Good luck with your work!Daniel Z.

1 Answers

0
votes

Firebase Notification Messages can have an optional data payload. This payload is the same size as Data Messages.

So just use Notification Messages. If the app is killed, your notification will be displayed with the default push notification handler.

If your app is open, you don't have to show the notification, and can just perform your own logic with the notification data payload.