iphone - 使用 Apple 的推送通知服务 (APNS) 避免重复

标签 iphone ios ipad push-notification apple-push-notifications

我们引用了 Apple 的 TN2265 ( https://developer.apple.com/library/ios/technotes/tn2265/_index.html ) 在我们的应用程序中实现错误处理,它向我们的用户发送推送通知。文档建议我们异步处理错误,具体来说:

If you get six bytes back, that's an error response that you can check for the response code and the ID of the notification that caused the error. You'll need to send every notification following that one again.

是不是在一系列通知中,如果一个通知失败,那么它后面的所有通知肯定都失败了?如果不是,那么如何避免向给定设备重复发送相同的通知?

最佳答案

是的,在那种情况下,它后面的所有通知都保证不会被 APNS 服务器处理。

当 APNS 检测到无效消息时,它会将错误响应写入套接字并关闭连接。在您收到该错误响应之前,您可能已经在同一个套接字上向 Apple 发送了更多消息。所有这些都不会到达 Apple。创建新套接字后,您应该重新发送所有套接字。

没有重复的风险。

关于iphone - 使用 Apple 的推送通知服务 (APNS) 避免重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19000176/

相关文章:

ios - Xcode 对带有 M1 芯片的 Macmini 抛出 arm64 架构错误

iphone - 锁定屏幕后重新加载 iPhone 应用程序

iphone - iPhone iOS是否可以创建带有2个激光指示器和iPhone的测距仪?

ios - 通过按详细 View 的按钮隐藏和取消隐藏 masterView

iphone - 存档应用程序时,Xcode 认为我的 Icon@2x.png 适用于 iPad 而不是 iPhone 4

iphone - 如何将 iPhone 联系人拉入 UIWebView?

iphone - 如何将时间值的NSString表示形式转换为包含小时和分钟的两个NSInteger形式?

iphone - 为什么 Mobile Safari 中的地理定位不如 native 应用程序中的位置准确?

ios - 如何跟踪转推和 Facebook 评论?

ios - UITabBarController 应用程序在每个选项卡中都有 UIWebViews