I'm developing 3rd party server to use APNS. My server opens a connection to APNS, sends several messages, then close connection like this.
$apns = stream_socket_client( ... );
foreach( $data as $row )
{
SendPush( $apns, $row );
...
}
...
fclose( $apns );
I've developed a server with php, and done tests with 4 devices - iPhone4 * 2 and i Pod Touch *2, then I found some device miss its push nofitication.
When I tried to send Push by this with this sequence, only iPhone A received its Push notification.
iPhone A -> iPod A -> iPhone B -> iPod B
With below sequence, only iPod A received Push notificaton.
iPod A -> iPhone A -> iPod B -> iPhone B
And I tried this sequence - iPhone A -> iPhone B -> iPod A -> iPod B, then iPhone A&B received their push, but iPod A&B didn't. With iPod A -> iPod B -> iPhone A -> iPhone B, only iPods received push.
I开发者_如何转开发 used SSL certificate for production. When I send one push per one connection or used certificate for development, there was no problem - all devices recevied their pushs well. Why this happen?
This is what I think you should do:
1) Enable an AppID to use APNS. For development/production. 2) Re-generate the provisioning/distribution profile that you signed your app with. Careful , you have to use a provisioning profile that uses the AppID mentioned above. If you are running the app in development and trying to send with an appID enabled for production , that's not going to work.
3) Be aware of the notifications flow. The server sends the notification to the APNS and the APNS sends the notification to the device IF the device is on && connected to the internet. If not , the APNS will not store a queue. If one notification fails , than all of the notifications following in the pipe will fail. There is a WWDC session video about push notifications and you can see graphically how this works.
That means that is you send to device1 , device2 and device3 (in this order) then you have this pipe (order) . If device2 is offline or shut down , device3 will not get it's notification either. You have to manage this on the server side and resend the failed ones and the ones that were following it.
I hope this helps. Sorry for my English.
Regards,
George
精彩评论