0
votes

My application receives silent push notifications... works fine if the app is in foreground, but when moved to background it only receives them for a while (8-10 minutes) and after nothing for about one hour and after again few received (for 8-10 minutes) and again nothing...

I also realised, that calling

FIRMessaging.messaging().appDidReceiveMessage(userInfo)

in background is causing this warning:

FIRMessaging receiving notification in invalid state 2

I am wondering, if these two things can't be linked... Firebase stops sending silent push messages after a while, because they are not confirmed when received in background???

Thanks a lot, Jan

UPDATE:

One part answered by Firebase support. There is no link between this warning and notifications delivery. Confirmation is used only for Analytics, for nothing else. Warning to be corrected, but not linked to my issue.

UPDATE:

I have just found these questions, which are describing the issues with silent push notifications delivery in background:

Silent push notifications only delivered if device is charging and/or app is foreground

didReceiveRemoteNotification:fetchCompletionHandler not being called when app is in background and not connected to Xcode

iOS8.1.2 didReceiveRemoteNotification method not called when device is not plugged in

No obvious solution there... at least I don't see it.

1

1 Answers

2
votes

Sounds to me like you've got your app configured correctly for FIRMessaging(), but not for APNs.

Here's the thing: Firebase Messaging is only used for sending data-only messages when your app is in the foreground. By definition, it doesn't work when your app is in the background -- if you're trying to send messages to your app in the background, Firebase Cloud Messaging routes your message through APNs, which is received through normal APNs-y methods, like application(_:didReceiveRemoteNotification:fetchCompletionHandler:).

If you want more information on this topic, maybe I humbly suggest the Debugging Firebase Cloud Messaging on iOS post on the Firebase blog.