Answer the question
In order to leave comments, you need to log in
Push Notifications and iPhone. WTF?
I decided to try push notifications in action. I wrote a script on the server - there are several messages in the array, and it sends all these messages to a hundred in a cycle. And on the client, a normal empty application (single view application which is in xCode). So, I sent a push. All messages instantly came to the device. Opened the application, the iPhone hung before opening. Then the screen went blank. And that's it. It's been like this for the second hour... I re-send the push, the sound comes out, that is, it receives. It does not turn off and does not turn on ... What should I do?
Answer the question
In order to leave comments, you need to log in
Here is the PHP code
<?php
$deviceToken = 'ab7667338108361e57d82788e878b650bc7edf8ff8f874a56f1f129f43a573dc';
$passphrase = '1234';
$message = 'Привет! Как дела?)))';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$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 to connect: $err $errstr" . PHP_EOL);
for($i = 0; $i < 5; $i++){
$body['aps'] = array(
'alert' => $message.$i,
'sound' => 'chime'
);
$payload = json_encode($body);
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
$result = fwrite($fp, $msg, strlen($msg));
}
if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
echo 'Message successfully delivered' . PHP_EOL;
fclose($fp);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question