Notification Service Extension when device is offline

Hi all,

I have a messenger app, in previous iOS version, when my app is in background, I use voip push to wake up my app and connect XMPP ro receive message from server. When iOS 13 is release, I have to use another way.

As correct answer from KevinE here

"4) Using VoIP pushes to trigger syncs or other non-VoIP use cases


VoIP pushes were always intended to specifically support call notifications and nothing else. The good news here is that using Notification Service Extension is the best substitute for most of the functionality that you previously handled with PushKit:


https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension


A few examples:

  • For general messaging, you can connect to your server in the extension delegate, download any missed messages, and then update the notification content as appropriate.
  • The same approach can be used to tell the user about calls missed while the device was offline and/or pending voicemails.
  • For non-user facing functionality, like data synchronization or other app maintenance, I would recommend checking out the new BackgroundTasks framework:


https://developer.apple.com/documentation/backgroundtasks"

I changed to Notification Service Extension, when receive a notification, I download message and insert it to database.

Everything works fine, util I realize that, if user A send many message to user B when user B is offline, then when user B turn on internet connection, only the last message is sent to user B, all the previous message that Apple stores in APNs is discarded!

What is solution for this?

Thanks.