Ad

Is Firebase Not Always Sending Notifications Through APNs?

I noticed that the firebase documentation says the following:

If a notification payload is provided, or the content_available option is set to true for a message to an iOS device, the message is sent through APNs, otherwise it is sent through the FCM connection server.

Can someone please explain what that means?

I thought ALL push notifications sent to iOS devices, are first sent to Apple, and then forwarded by Apple to the corresponding device/s, but here it is implied that they're sending messages directly to the device?

Is that even possible when the app is shut on iOS?

I'm confused, thank you.

Ad

Answer

When the app is in the foreground, FCM can connect directly rather than go via APNs for data type messages. Messages sent when in the background are delivered via APNs as you'd expect. You can actually take a look at the source of the FCM client if you're so inclined!

You can control whether this is used with the shouldEstablishDirectChannel property.

From the sending perspective, you don't need to worry too much about this - its handled transparently as part of the FCM service based on the type of the message and whether there is a client connected.

Ad
source: stackoverflow.com
Ad