苹果推送通知
我的 Apple 通知有时在设备上收到一些无法到达的通知。 请帮助我并告诉我苹果通知失败时的不同场景。
任何帮助将不胜感激。
My Apple Notification sometime received some get failed to reach on device.
Please help me and tell different scenarios when an Apple Notification fails.
Any help would be very appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
推送通知不起作用可能有多种原因。此检查清单可以帮助您找到一些:
APNS 检查列表
提供商应安装 Entrust Secure Server CA 根证书。这允许 TLS/SSL 验证完整的 APNs 服务器证书链。此根证书可以从 Entrust 网站下载。
开发环境中的设备令牌不适用于生产推送服务。每个推送环境将为同一设备发出不同的令牌。如果无效的设备令牌发送到错误的环境,推送服务会将其视为无效令牌并丢弃通知。
如果您从设备中删除应用,然后向其发送推送通知,则设备令牌会被拒绝,并且无效的设备令牌应出现在反馈服务上。但是,如果这是设备上最后一个启用推送的应用程序,它将不会显示在反馈服务中。这是因为,在发送删除通知之前,删除最后一个应用程序会破坏与推送服务的持久连接。
推送提供商通常位于防火墙后面。要发送通知,您需要打开 TCP 端口 2195。要访问反馈服务,您需要打开 TCP 端口 2196。通过 Wi-Fi 连接到推送服务的设备需要打开 TCP 端口 5223。
推送服务的IP地址范围可能会发生变化;我们期望提供商将通过主机名而不是 IP 地址进行连接。但是,整个 17.0.0.0/8 地址块都分配给 Apple,因此您可以在防火墙规则中指定该范围。
我们可以启用 APNS 日志记录,在设备上安装配置文件 APNsLogging.mobileconfig,方法是将文件放在 Web 服务器上并使用设备上的 Safari 将其下载到某个位置,或者将其作为电子邮件附件发送并在在您的设备上发送邮件。我们可以使用 mdm 推送配置文件。
更多详细信息可以在此处找到
There could be various reasons for push notification not working. This check list can help you find few :
APNS CheckList
Provider should install the Entrust Secure Server CA root certificate. This allows TLS/SSL to verify the full APNs server cert chain. This root certificate can be downloaded from Entrust's site.
The device token from development environment will not work on production push service. Each pushenvironment will issue a different token for the same device. If an invalid device token is sent to the wrong environment, the push service will see that as an invalid token and discard the notification.
If you remove your app from your device and then send a push notification to it, you would expect to have the device token rejected, and the invalidated device token should appear on the feedback service. However, if this was the last push-enabled app on the device, it will not show up in the feedback service. This is because deleting the last app tears down the persistent connection to the push service before the notice of the deletion can be sent.
Push providers are often behind firewalls. To send notifications, you will need to have TCP port 2195 open. To reach the feedback service, you will need to have TCP port 2196 open. Devices connecting to the push service over Wi-Fi will need to have TCP port 5223 open.
The IP address range for the push service is subject to change; the expectation is that providers will connect by hostname rather than IP address. However, the entire 17.0.0.0/8 address block is assigned to Apple, so you can specify that range in your firewall rules.
We can enable APNS logging, install the configuration profile APNsLogging.mobileconfig on device by either putting the file on a web server and downloading it location using Safari on your device, or by sending it as an email attachment and opening the attachment in Mail on your device. We can use mdm to push profile.
More details can be found here
苹果明确表示不保证通知。他们可能会因为各种原因而失败。例如,如果您在发送第一个通知之前向设备发送多个通知,则先前的通知将被删除。我似乎记得在文档中的某处读到沙盒环境有时无法传递消息,以便您可以测试失败代码。
Apple explicitly states that notifications are not guaranteed. They can fail for all sorts of reasons. For example, if you send more than one notification to a device before the first one has been delivered, the prior ones are deleted. I seem to remember reading in the documentation somewhere that the sandbox environment occasionally fails to deliver a message so that you can test your failure code.