如何确保iOS应用收到服务器发送的每推送通知? [英] How to ensure that iOS app received EVERY push notification send by server?

查看:237
本文介绍了如何确保iOS应用收到服务器发送的每推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知的是:


  • 应用程序不会收到推送通知,如果它是在后台或离线模式(应用程序用户的动作后得到了一次:点击通知或应用程序图标的)。

  • 苹果推送通知服务保持的只有一个最后的通知:当设备处于脱机状态。一旦设备连接到互联网,发送的APN的最后通知。

  • 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.

如何解决此问题?


  • 刚刚达到应用最新的通知(不是设备)必须反映未在应用程序执行尚未通知的实际数量。所以,那么我可以从服务器上最后一个 N 的通知下载并随时应用程序实施。

  • 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.

现在的问题是:

服务器怎么知道的通知在应用程序中实现,哪一个不是?

通知必须是每个设备。为什么?例如,通知必须在每个设备中实现从核心数据删除的对象。因为只有一个用户可以同时登录的乘法装置。

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.

推荐答案

您应该跟踪任务的状态服务器(删除记录或任何你的应用程序需要做的),并有客户报告回来时,任务完成。然后标记为已完成的任务。

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.

这篇关于如何确保iOS应用收到服务器发送的每推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆