Push notification 如何向不同的APNS URL发送1次

Push notification 如何向不同的APNS URL发送1次,push-notification,passbook,Push Notification,Passbook,我给通行证打了一个提示。如何发送到两个网址只有一行?我使用以下代码:$ConnectAPNS=stream\u socket\u client('ssl://gateway.sandbox.push.apple.com:2195“,$err,$errstr,60,STREAM\u CLIENT\u CONNECT,$streamContext); $ConnectAPNS1=stream\u socket\u client('ssl://gateway.push.apple.com:2195“,

我给通行证打了一个提示。如何发送到两个网址只有一行?我使用以下代码:
$ConnectAPNS=stream\u socket\u client('ssl://gateway.sandbox.push.apple.com:2195“,$err,$errstr,60,STREAM\u CLIENT\u CONNECT,$streamContext);

$ConnectAPNS1=stream\u socket\u client('ssl://gateway.push.apple.com:2195“,$err,$errstr,60,STREAM\u CLIENT\u CONNECT,$streamContext);

所有存折APN请求都应该使用生产服务器,这样您就可以完全删除ssl://gateway.sandbox.push.apple.com:2195`线路。要发送多个设备的请求,只需在流打开时写入流即可

// Code edited to match info provided in the comments below.
$to_push = array();
$payload = json_encode(array('aps' => ''));

while($device = mysql_fetch_array($query2,MYSQL_ASSOC)){ 
    $to_push[] = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $device['pushToken;])) . chr(0) . chr(mb_strlen($payload)) . $payload;
}

$ConnectAPNS = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $streamContext);

foreach ($to_push as $push)
    fwrite($ConnectAPNS, $push);

fclose($ConnectAPNS);

在上面的代码中,将$device_query替换为包含从数据库检索到的设备的对象。此外,请验证
pushToken
是否与您的列名匹配,如果不匹配,请将其替换为正确的值

所以$push=$apns_消息!如果$apns_消息包含
chr(0)。chr(0)。chr(32)。包装('H*',str_替换('',$device_标记))。chr(0)。chr(mb_strlen($payload))$有效载荷(或您准备apns消息的方式),然后是$apns_消息=chr(0)。chr(0)。chr(32)。包装('H*',str_replace('',,$to_push))。chr(0)。chr(mb_strlen($payload))$有效载荷;酷-那么在我上面的代码中更改$to_push变量的名称,这样你就不会把它和你的push令牌混淆了。但是我得到了这个错误:[02-May-2013 11:32:59 Europe/Berlin]PHP警告:fwrite()希望参数2是字符串,数组在第39行的/Applications/MAMP/htdocs/passesWebserver/pushNewPass/pushNotification.PHP中给出