Since Last week Friday (apr 23) everything is working, i received both sandbox and production notification. But when i check now, notification is not working. I checked my .pem file is valid till Dec 2021, When i run the below code the result is 'Message successfully delivered'. I don't know what happened. Please help me.
<?php
$deviceToken = "a9eb9cd54446b5cad4fa3636dbe822b5d420126fdbb632ef79b4bf07bfd8b6b4";
$passphrase = 'secret';
$message = "Hello world!";
$ctx = stream_context_create();
$passphrase = 'secret';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'certi.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
/* $fp = stream_socket_client(
'ssl://gateway.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);*/
$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 tess connect: $err $errstr" . PHP_EOL);
}
$body = array('aps' => array('alert' => $message,'sound' => 'default','badge' => 1),'rewards_badge' => 1);
$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);
?>
Thanks