1

I have coded Push Notifications (APNS, Apple Push Notification Service) for an iPhone App with PHP. Everything is working fine while no app is deleted from a device. I use the Feedback Service from Apple do get the deleted devices. If I get devices I mark them as INACTIVE in my database to send no further push notification to those devices.

The problem is that Apple is slow. If you delete the app from your device a request is send to Apple and I collect the devices by using the Feedback Service. But Apple is not forwarding the inactivated devices instantly so I get the following error because I can't send push notifications to a inactive device:

PHP Warning: fwrite(): SSL: Broken pipe in apns.php on line 155

My Feedback Service script runs every 5 minutes but the update from Apple comes every 10-15 minutes. If I send a push notification within the 10-15 minutes the above error appears because in the database the device is still marked as ACTIVE and on the Apple server the device is marked as INACTIVE.

There is no problem to connect to the Feedback Service or to the Push Service but I don't always get devices from the Feedback Service.

Greets, TheFox

4

1 回答 1

1

Apple.com 开发者论坛 (https://devforums.apple.com/thread/114446) 的回答:

您的服务器需要检测断开连接并在必要时重新连接。当涉及网络时,没有什么是“即时的”;总是有一些延迟,代码需要考虑到这一点。此外,请考虑使用增强的二进制接口,以便检查返回响应并了解连接断开的原因。由于 TCP 保持活动,连接也可能被丢弃,这超出了 Apple 的控制。

因此,如果服务器检测到断开连接,我会将所有设备设置为INACTIVE 。

于 2011-07-29T08:42:11.970 回答