my swift 2 app goes online a few seconds ago. i can send single push notifications to one device.
but if i send one notification to two devices, the devices get no notifications. the log "Message successfully delivered" will be shown.
here my php file:
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'xxx.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'xxx');
// Open a connection to the APNS server
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp) { exit("Failed to connect: ".$err." ".$errstr." ". PHP_EOL); }
for ($y = 0; $y < count($deviceTokens); $y++)
{
$body['aps'] = array('silentPush' => 0, 'alert' => 'Test', 'badge' => $badgeNumber, 'sound' => 'default');
$payload = json_encode($body);
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceTokens[$y]) . pack('n', strlen($payload)) . $payload;
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
{
echo 'Message not delivered' . PHP_EOL.'<br />';
}
else
{
echo 'Message successfully delivered' . PHP_EOL.'<br />';
}
}
Where is my mistake?