ios APNS(Apple 推送通知服务)可靠性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13897575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
APNS (Apple Push Notification Service) reliability
提问by Faust V
Our app uses APNS to receive Push Notifications. However, our client claims that some of their devices were not receiving notifications and argues to they 'must' make sure the notifications to be delivered 100%. But I have read somewherethat APNS is not 100% reliable and there should be cases which the notifications are not delivered.
我们的应用程序使用 APNS 接收推送通知。但是,我们的客户声称他们的一些设备没有收到通知,并争辩说他们“必须”确保 100% 发送通知。但是我在某处读到APNS 不是 100% 可靠的,应该存在未发送通知的情况。
I'm currently panic at how we could make sure APNS to received anytime. I have read that a casewhich may APNS not delivered (device may offline). But our test showing that even the device is online (Wifi or 3G), sometimes APNS were not delivered.
我目前对我们如何确保随时接收 APNS 感到恐慌。我读过一个可能 APNS 未交付的案例(设备可能脱机)。但是我们的测试表明,即使设备在线(Wifi 或 3G),有时也无法交付 APNS。
Is there any specific case which may APNS will not delivered? Or is there anything we (developers) can do with codes to make sure to receive all notifications? What I have done in the code is just registering the app to remote notification and write didRegisterForRemoteNotificationsWithDeviceToken, then throw the device token to our server.
是否有任何特定情况下 APNS 可能无法交付?或者我们(开发人员)可以用代码做些什么来确保收到所有通知?我在代码中所做的只是将应用程序注册到远程通知并编写 didRegisterForRemoteNotificationsWithDeviceToken,然后将设备令牌扔到我们的服务器。
Any help would be appreciated, for our client almost kill us if ALL of their devices not receiving APNS!
任何帮助将不胜感激,因为如果他们的所有设备都没有收到 APNS,我们的客户几乎会杀死我们!
回答by Karthik
- APNS is based on Apple Servers, and Apple doesn't give any guarantee on successful message delivery.
- If the app is open (i.e. the user is using the app) while the notification arrives, iOS doesnt show a notification message, you need to handle it.
- Notification shows up only when the app is backgrounded or killed.
- Also implement feedback service on your server side; will help you get rid of old unwanted tokens(users who deleted the app or disabled notifications thru settings).
- Dont send too many notifications to a device within a short span of time, coz APNS caches only 1 message/device (if the device is offline). So it can deliver the message when the device comes online. Am not sure how long the message is cached though.
- APNS 是基于 Apple Servers 的,Apple 对成功的消息传递不做任何保证。
- 如果应用程序打开(即用户正在使用该应用程序)而通知到达时,iOS 不会显示通知消息,您需要处理它。
- 通知仅在应用程序后台运行或终止时显示。
- 同时在您的服务器端实现反馈服务;将帮助您摆脱旧的不需要的令牌(删除应用程序或通过设置禁用通知的用户)。
- 不要在短时间内向设备发送太多通知,因为 APNS 仅缓存 1 条消息/设备(如果设备处于离线状态)。因此,它可以在设备上线时传递消息。我不确定消息缓存了多长时间。
Or just implement Pusher... http://pusher.com
或者只是实现 Pusher ... http://pusher.com
回答by pdaire
We're facing the same problem. As everybody said, APNS is a best effortservice so you can't be sure every notification will be delivered, but what you can do is to be sure of which ones have been received. This is what we're about to do. We register in our backend each notification que shipand the mobile app reports back each notification it receives. Then we set a maximum time of waiting for a notification to be received, if we don't receive the report back we try again.
我们面临同样的问题。正如大家所说,APNS 是一种尽力而为的服务,因此您不能确定每个通知都会被发送,但您可以做的是确定已收到哪些通知。这就是我们要做的。我们在注册我们的后端每个通知阙船和移动应用报告回来,每次收到通知。然后我们设置等待接收通知的最长时间,如果我们没有收到报告,我们再试一次。
I hope it might be helpful to someone (even 2 years later)
我希望它可能对某人有所帮助(即使是 2 年后)
回答by steve
It says it quite clearly in the Apple Docs that it is not 100% gauranteed and nor should it be used as so. Its sent with "best effort".
它在 Apple Docs 中非常清楚地表明它不是 100% 保证的,也不应该如此使用。它以“最大努力”发送。
回答by Jarvis The Avenger
As per Apple's guidelines, APNS is not 100% reliable service that means your app may not get the push notifications from Apple servers due to some of following reasons:
根据 Apple 的指南,APNS 不是 100% 可靠的服务,这意味着您的应用可能由于以下某些原因无法从 Apple 服务器获得推送通知:
- Device is offline
- Your app is in the foreground state, you need to manage the push notification.
- 设备离线
- 您的应用处于前台状态,您需要管理推送通知。
Note: Apple rejects app which makes compulsion using notification services. (I have faced it in one of my App)
注意:Apple 拒绝强制使用通知服务的应用程序。(我在我的一个应用程序中遇到过它)
For more information, you can look into this answer
有关更多信息,您可以查看此答案