I've developed an app for ios and it has been published on the app store. The push notification system worked fine in development but now, i receive no notification at all. Before publishing, i've generated the Development Provisioning Profiles associated with an App Id having enabled the push and configurated the Production Push SSL Certificate. I've downloaded the Production Push SSL Certificate and installed it in my keychain access, exported it and its private key, converted them to pem and united them in a unique pem file, which i uploaded to my server containing the php script which send the notifications. I've changed the server in my php script to the one of production (ssl://gateway.push.apple.com:2195). Still the script seems to send the notification and doesn't fire any error.
What i'm missing?
Here's my php script:
<?PHP
/* Here there's Code to retrieve device tokens and put it in a variable $deviceToken from my online database and then...*/
$message = "Message to be sent";
$payload = '{
"aps" :
{ "alert" : "'.$message.'",
"badge" : 1,
"sound" : "bingbong.aiff"
}
}';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'secret');
// se l'app è già sull'appstore togliere sandbox e lasciare solo gateway.push.apple.com:2195
// invece di gateway.sandbox.push.apple.com:2195
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if(!$fp){
print "Failed to connect $err $errstrn";
return;
} else {
print "Notifications sent! </br>";
}
foreach($devArray as $deviceToken){
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack ("n",strlen($payload)) . $payload;
print "sending message :" . $payload . "n to device:".$deviceToken."</br>";
fwrite($fp, $msg);
}
fclose($fp);
?>
print "sending message :" . $payload . "n to device:".$deviceToken."</br>";
? – CainaSouza