So. I installed my app and under setting it appears that my app is registered for push notification. I also got the token , made the pem file , checked to see if it is correctly used by running this command
apn stefanandrei$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert apns-dev.pem -debug -showcerts -CAfile server-ca-cert.pem
I am using this php code:
// send our authentification file
stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns-dev.pem');
// open a connection to the sandbox server
$apnsConnection = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
// creating the notification message (256 Byte max)
// your device token here
$deviceToken = 'ba672efe 4d6b5b7b db89a08a e9b36da2 ada14b00 df2f0b36 3eb6515b 08d57879';
// your message goes here
$message = "Your push notification text goes here.";
// define a sound file if you want here
$sound = 'mySoundFile.caf'; //name of the sound file inside the XCode project.
// Construct the notification payload
$body = array();
$body['aps'] = array('alert' => $message);
$badge = (int)$argv[2]; // a number which will be displayed over the apps icon
if ($badge)
{
$body['aps']['badge'] = $badge;
}
if ($sound)
{
$body['aps']['sound'] = $sound;
}
$payload = json_encode($body);
// remove blanks and pack it.
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
echo $msg;
// push the message through APNS
fwrite($apnsConnection, $msg);
//close APNS connection
fclose($apnsConnection);
?>
<code>
The problem is that don't receive a notification.I don't receive anything .What can i do.