14
votes

I'm creating an iOS and Android native app, using Firebase for sending push notifications.

It's working fine, but when I switch off my devices and send some notifications, after starting the devices, I just receive the last one sent for iOS, and the same for Android.

Is there a way to receive all the push notifications even when the devices are offline and they're started?

1
I also have problem like you. Turn off Wi-Fi send 5 push notification after turn on Wi-Fi receive only one push notification. I'm read below answer but me did not help. How are you resolve problem?user_odoo

1 Answers

18
votes

Referencing a couple of references:

iOS:

Apple Push Notification service includes a Quality of Service (QoS) component that performs a store-and-forward function. If APNs attempts to deliver a notification and the destination device is offline, APNs stores the notification for a limited period of time and delivers it when the device becomes available again. This component stores only the most recent notification per device and per app. If a device is offline, sending a notification request targeting that device causes the previous request to be discarded. If a device remains offline for a long time, all its stored notifications in APNs are discarded.

  • This component stores only the most recent notification per device and per app.
  • If a device is offline, sending a notification request targeting that device causes the previous request to be discarded.

This would mean that only one notification is preserved and that sending a new one replaced the old one. So I don't think it's possible.

Local and Remote Notification Programming Guide

Android:

On Android and Web/JavaScript, you can specify the maximum lifespan of a message. The value must be a duration from 0 to 2,419,200 seconds (28 days), and it corresponds to the maximum period of time for which FCM stores and attempts to deliver the message. Requests that don't contain this field default to the maximum period of four weeks.

and

Currently, time_to_live is not supported for notification messages on iOS

and

If the device is not connected to GCM, the message will be stored until a connection is established (again respecting the collapse key rules). When a connection is established, GCM delivers all pending messages to the device. If the device never gets connected again (for instance, if it was factory reset), the message will eventually time out and be discarded from GCM storage. The default timeout is 4 weeks, unless the time_to_live flag is set.

and

Finally, when GCM attempts to deliver a message to the device and the application was uninstalled, GCM will discard that message right away and invalidate the registration token. Future attempts to send a message to that device will result in a NotRegistered error.

  • When a connection is established, GCM delivers all pending messages to the device.
  • If the device never gets connected again (for instance, if it was factory reset), the message will eventually time out and be discarded from GCM storage.
  • The default timeout is 4 weeks, unless the time_to_live flag is set.
  • Finally, when GCM attempts to deliver a message to the device and the application was uninstalled, GCM will discard that message right away and invalidate the registration token.

Meaning it should be receiving the pending messages. Unless the device is factory reset or uninstalled.

About FCM Messages

Messaging Concepts and Options (although this is deprecated and now suggests to reference FCM messaging, linked above)