3

When observing WhatsApp, and similar chat apps, I can see the following behaviour:

  1. Turn off internet connection (both cellular and WIFI).
  2. Make sure chat app is not active (in background).
  3. Send multiple messages to my device (via other devices).
  4. Turn on internet.
  5. In a matter of seconds, all messages are shown as notifications.

I can reproduce this scenario every time I try.

Now I am working on my own iPhone app and I can't seem to figure out how to implement this behaviour. As far as I understand this could have been implemented in several ways:

Using the QoS feature of APNS:
I read that the QoS stores a message if it wasn't delivered to the device, and sends it again when the device reconnects. This solution, however, is not making sense because of two reasons:

  1. QoS is said to save only one undelivered message at a time. But it my case, I get more than one message.

  2. The messages are shown instantly, the moment as I turn the internet connection, and QoS documentation says it may take some time to get the undelivered message.

Using a background service or listen to connectivity changes:
Regarding the background service, I know the closest thing to a running background service is Background Fetch but again it dose not seem to fit here because it is periodical.
And I also wasn't able to find any callback I can hookup to, to know when connectivity had changed while I am in background, and perform some actions.

Do you have any idea how could one implement this feature for an iPhone app? (QoS? Other background APIs?)

Yaron Levi
  • 12,535
  • 16
  • 69
  • 118

0 Answers0