How to ensure that iOS app received EVERY push notification send by server?

送分小仙女□ 提交于 2019-12-21 19:40:37

问题


It is widely known that:

  • app doesn't receive push notification if it is in background or offline mode (app gets it once after user's action: tap on notification or app icon).
  • Apple push Notification service keep only ONE last notification when device is offline. Once device is connected to internet, APNs sends the last notification.

How to solve this?

  • very latest notification that just reached the app (not device) must reflect the actual number of notifications that are not implemented in the app yet. So, then I can download from the server last n notifications and implement them in the app at any time.

The question is:

How the server knows what notifications were implemented in the app, and which one not?

Notifications must be per device. Why? For instance, notification "remove object from Core Data" must be implemented in every device. Because only one user can be logged in on multiply devices at time.


回答1:


You should track the state of the task (delete record or whatever your app needs to do) on the server and have the client report back when the task is done. Then flag the task as done.

Don't use push notifications as a reliable delivery method for your tasks, you will fail. Use the notifications as complementary part of your setup.

So for example when your app receives a notification, it can sync with the backend, to retrieve the tasks flagged as not done, execute them and then let the backend know that it's done.



来源:https://stackoverflow.com/questions/32932920/how-to-ensure-that-ios-app-received-every-push-notification-send-by-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!