且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

APNS推送通知不适用于生产证书

更新时间:2022-12-06 14:21:42

设备令牌在开发和生产环境中是不同的.生产设备令牌在开发环境中无效,反之亦然.您应该为生产令牌和开发令牌维护不同的数据库.现在,您将它们混合在一起了,要区分它们有点棘手.

Device tokens are different for development and production environment. Production device tokens are invalid in development environment and vica versa. You should have maintained different databased for the production tokens and development tokens. Now that you have them mixed it's a bit tricky to tell them apart.

您可以通过发送所有设备令牌的通知来找出哪些设备令牌在生产环境中无效(这意味着它们可能是开发令牌).每次发送后,您应该尝试读取Apple的错误响应.错误响应8表示无效的设备令牌.对于该读取,您应该使用较长的超时时间(因为从Apple获得错误响应有时会花费一些时间.)

You can find out which device token are invalid in the production environment (which means they are probably development tokens) by sending notifications for all your device tokens. After each send you should try to read an error response from Apple. Error response 8 means invalid device token. You should use a long timeout for that read (since it sometimes takes time to get the error response from Apple).