E
E
Empty User2015-05-13 22:47:41
iOS
Empty User, 2015-05-13 22:47:41

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

2 answer(s)
A
Alexey, 2015-05-14
@dimash07

Did you try reboot? Home plus food hold for 10 seconds

E
Empty User, 2015-05-14
@dimash07

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 question

Ask a Question

731 491 924 answers to any question