ios - One push arrives - but not when sending >1 message at once -


i've problem, can send 1 message @ once. code working quite fine:

$fp = stream_socket_client(         'ssl://gateway.sandbox.push.apple.com:2195', $err,         $errstr, 60, stream_client_connect|stream_client_persistent, $ctx);      if (!$fp)         exit("failed connect: $err $errstr" . php_eol);      echo 'connected apns' . php_eol ."<br><br>";      // create payload body     $body['aps'] = array(         'alert' => $message,         'sound' => 'default',         'badge' => 1         );     // encode payload json     $payload = json_encode($body);      // build binary notification     $msg = chr(0) . pack('n', 32) . pack('h*', $token[1]) . pack('n', strlen($payload)) . $payload; $result = fwrite($fp, $msg, strlen($msg)); if (!$result)     echo '<br><div style="color:red">message not delivered' . php_eol.'</div><br><br>'; else     echo '<br><div style="color:green">message delivered' . php_eol.'</div><br><br>'; 

but when try concat messages (msg), message worked - nothing arrives..

$ait = new arrayiterator($token); $cit = new cachingiterator($ait); $msg2 = ""; foreach ($cit $devicetoken) {      if($devicetoken != null && $message != null) {         $body['aps'] = array(         'alert' => $message,         'sound' => 'default',         'badge' => 1         );         $payload = json_encode($body);          $msg2 .= chr(0) . pack('n', 32) . pack('h*', $devicetoken) . pack('n', strlen($payload)) . $payload;     }     else throw new exception('should not null'); } echo $msg2; $result2 = fwrite($fp, $msg2, strlen($msg2)); fclose($fp); 

can help?

edit: forgot add line "$msg2 = "";" in front of foreach loop.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -