English 中文(简体)
APN 设备 Tok 过一段时间后停止接收任何 apns 。
原标题:APN Device Token stops receiveing any apns after some time

我有定期从服务器接收 APN 的应用程序。 它在启动时呼叫注册 ForRemoteNotificTypes, 然后定期( 工作时) 重新刷新它。 它正确地接收设备标记并发送到后台服务器, 供日后使用 。

But there is a problem:
- after app is started, it correctly recieves all apns sent from my server via device token generated by iphone at app start.
- but when app stays in background (without any restarts) for like 8-12 hours it stops to recieve anything
- by checking app/server logs i see that app properly reasks for new token via registerForRemoteNotificationTypes periodically, properly receives exactly the same token it has from very start, backstage server continue to use it for sending apns and sending them to apple without any errors via socket
- but messages simply not showing on device any more, didReceiveRemoteNotification not called at all
- Exiting app manually and restarting it helps - registerForRemoteNotificationTypes return another token, which works very well - server uses it for sending apns and device immediately receives them, as expected.

所以它似乎就像 iphone reasking 苹果服务器, 仅在程序启动时, 然后硬地刻录它。 但是, message 仍然有类似 ttl 的时段 。

是否有办法强制 iphone 返回最新的、 实际的设备标记? 如何强制 iphone 重新检查苹果服务器上的设备标记, 以确保它真的正常且健康?

请救救我!


UPD: managed to narrow down problem - app in question using sandbox apn environment (since we are developing it) - i changed APN sending procedure to extended protocol and now see that after some time aplle sandbox server starting to reply with error 8 - invalid token. at the same time device receiving the same old token from registerForRemoteNotification. so there is definitely a problem with refreshing token by iOS

问题回答

after switching from sandbox environment to production one - problem is gone. so there is a difference between sandbox and production gates: device token ttl in sandbox environment is much shorter than in production. still, device token on the phone itself is the same for both environments. so using sandbox environment makes this problem - phone returns invalid (already invalidated on server) device token for application





相关问题
Port Number for Incoming Apple Push Notifications

What network services, port numbers, outgoing incoming or both, need to be open on a network for an ipod touch to receive Apple Push Notifications? I know the outgoing port number to set when sending ...

Push notifications dialogue

Is there any way I could make the "Would you like to enable push notifications..." dialogue not to come up upon first time application launch but rather on some other action in the application? ...

热门标签