APNS:设备种类有限制吗?

发布于 2024-10-21 13:47:10 字数 804 浏览 3 评论 0原文

我正在开发第 3 方服务器以使用 APNS。我的服务器打开与 APNS 的连接,发送几条消息,然后像这样关闭连接。

$apns = stream_socket_client( ... );

foreach( $data as $row )
{
    SendPush( $apns, $row );
    ...
}

...


fclose( $apns );

我用php开发了一个服务器,并用4个设备进行了测试 - iPhone4 * 2和i Pod Touch *2,然后我发现有些设备错过了推送通知。

当我尝试按此顺序发送推送时,只有 iPhone A 收到了推送通知。

iPhone A -> iPod A -> iPhone B-> iPod B

按照以下顺序,只有 iPod A 收到推送通知。

iPod A -> iPhone A -> iPod B -> iPhoneB

我尝试了这个序列 - iPhone A -> iPhone B-> iPod A -> iPod B、然后是 iPhone A 和 B 收到了推送,但 iPod A 和 B 没有收到推送。与 iPod A -> iPod B -> iPhone A -> iPhone B,只有 iPod 收到推送。

我使用 SSL 证书进行生产。当我为每个连接发送一个推送或使用证书进行开发时,没有问题 - 所有设备都很好地收到了推送。为什么会发生这种情况?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白馒头 2024-10-28 13:47:10

我认为您应该这样做:

1) 启用 AppID 以使用 APNS。用于开发/生产。
2) 重新生成您用于签署应用程序的配置/分发配置文件。小心,您必须使用使用上述 AppID 的配置文件。如果您正在开发中运行应用程序并尝试使用为生产启用的 appID 进行发送,那么这是行不通的。

3) 注意通知流程。服务器将通知发送到 APNS,并且 APNS 将通知发送到设备(如果设备处于开机状态)&&连接到互联网。
如果不是,APNS 将不会存储队列。如果一个通知失败,则管道中后续的所有通知都将失败。有一个关于推送通知的 WWDC 会议视频,您可以通过图形方式了解其工作原理。

这意味着您发送到 device1 、 device2 和 device3 (按此顺序),然​​后您就有了这个管道 (order) 。如果设备2离线或关机,设备3也不会收到通知。您必须在服务器端对此进行管理,并重新发送失败的邮件以及后续的邮件。

我希望这有帮助。
对不起我的英语。

问候,

乔治

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文