设备的最大号码发送到APNS插座SEVER [英] Max number of devices to send to APNS socket sever

查看:96
本文介绍了设备的最大号码发送到APNS插座SEVER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的推送通知脚本突然停止工作。该脚本执行以下操作:

Our push notification script that has worked for almost a year has suddenly stopped working. The script does the following:


  1. 查询一个DB的iPhone设备令牌的列表

  1. Queries a DB for a list of iPhone device tokens

打开一个SSL套接字连接到苹果的现场APNS服务器

Opens an SSL socket connection to Apple's live APNS server

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $apnsCert);
stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);
$fp = stream_socket_client($apnsHost, $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);


  • 创建了一个有效载荷具有255字节大小的消息

  • creates a payload with a 255 byte sized message

    $payload = '{
      "aps": {
         "alert": "' . $message . '",
         "badge": 1,
         "sound": "default"
      }
    }';
    


  • 遍历每个设备和有效载荷写入打开的连接。

  • Loops through each device and writes the payload to the open connection.

    $msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
    fwrite($fp, $msg);
    


  • 然后关闭连接。

  • The connection is then closed.

    fclose($fp);
    


  • 所以我的问题是在脚本this--一切都没有改变,但是发生了什么变化是数据库的大小。我创建了一个Web界面,允许用户有效载荷发送给所有iPhone的设备和运行时,只需要几秒钟发送/负载。是否有可能虽然这器件在DB(3500左右)的数量创造了什么问题?

    So my question is this-- nothing in the script has changed, but what HAS changed is the size of the database. I created a web interface that allows a user to send a payload to all iphone devices and when it runs it only takes a few seconds to send/load. Is it possible though that the number of devices in the DB (around 3500) is creating the problem?

    什么是我我可以发送推送通知的时候我写的插座装置的最大数量?做了最大或限制存在?

    What is the maximum number of devices that I can I send a push notification to when I write to the socket? Does a max or limit exist?

    推荐答案

    的问题是不发送到APNS设备的数量。原来,这个问题是,苹果改变了自己的API。现在,您需要检查每一个设备,看它是否仍然有效(即如果他们否认推notificaitons,如果设备中删除应用程序等)。如果设备不再接受来自您的应用程序推送通知,并发送一个它反正,苹果立即下降到您的APNS插座的连接。我现在有一个运行程序每天一次,检查并删除从我的数据库任何设备不再接受推送通知(苹果有这个列表)一个cronjob。但要小心 - 一旦你拉从苹果禁用的设备ID列表,苹果从他们的服务器中删除它,你可以的从不再次拉

    The problem wasn't the number of devices to sent to APNS. The problem turned out to be that Apple changed their API. You now need to check every single device to see if it's still valid (ie. if they are denying push notificaitons, if the device deleted the app, etc.). If the device no longer accepts push notifications from your app and you send one to it anyways, Apple immediately drops the connection to your APNS socket. I now have a cronjob that runs a program once a day that checks and deletes any devices from my database that no longer accept push notifications (Apple has this list). But be careful -- once you pull the list of disabled device ids from Apple, Apple deletes it from their server and you can never pull it again.

    您还需要更新您的推送通知code,以检查是否连接不断下降。当连接被删除,该程序需要重新建立连接,并再次尝试推。

    You also need to update your push notification code to check if the connection is ever dropped. When the connection is dropped, the program needs to reestablish the connection and try to push again.

    这篇关于设备的最大号码发送到APNS插座SEVER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆