我想向所有注册了应用程序的设备发送相同的消息,但是如何在不建立多个连接的情况下发送它们...
我当前的 PHP 代码:
ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp)
{
print "Failed to connect $err $errstr\n";
return;
}
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
fwrite($fp, $msg);
最佳答案
最重要的是,你不能。您需要向
Its not working like a email where you can have multiple recipients.
连接打开后,您可以发送一堆消息,这也是首选方式(基于 Apples SDK)。
来自 SDK:
You should also retain connections with APNs across multiple notifications. APNs may consider connections that are rapidly and repeatedly established and torn down as a denial-of-service attack. Upon error, APNs closes the connection on which the error occurred.
关于php - 如何在 iPhone 中一次性向多个设备发送推送通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5050363/