Push notification is successfully sent, but the device does not receive (occasionally)
- by ashiina
I have been having a problem where some devices will not receive a push notification, since yesterday.
The certificate / devicetoken seem to be correct,
since the device used to successfully receive push notifications until yesterday.
On the server-side, there are no errors or connection refusals,
and the push notification seems to be successfully sent every time.
But still, there are many occasions where the device does not correctly receive the push.
Some surrounding information:
I am doing this on the production environment.
No errors / connection refusals on the server-side
I am sending the exactly same JSON everytime.
2 of our devices are not receiving the push notification AT ALL since yesterday
1 of our device receives push notifications at a lower success rate (about 70%) than yesterday
1~2 of our devices still receive push notifications successfully even now.
All of the above devices were able to receive push notifications properly on the production environment until yesterday.
There is no difference in the server-side result for when the push is successful, and when the device doesn't receive it...
Therefore it is virtually impossible to identify the problem.
This is the server-side PHP code I am using:
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $this->apnsData[$development]['certificate']);
$fp = stream_socket_client($this->apnsData[$development]['ssl'], $error, $errorString, 100, (STREAM_CLIENT_C ONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
if(!$fp){
$this->_pushFailed($pid);
$this->_triggerError("Failed to connect to APNS: {$error} {$errorString}.");
}
else {
$msg = chr(0).pack("n",32).pack('H*',$token).pack("n",strlen($message)).$message;
$fwrite = fwrite($fp, $msg);
if(!$fwrite) {
error_log("[APNS] push failed...");
$this->_pushFailed($pid);
$this->_triggerError("Failed writing to stream.", E_USER_ERROR);
}
else {
error_log("[APNS] push successful! ::: $token -> $message ($fwrite bytes)");
}
}
fclose($fp);
The log tells me that the push was successful (Cutting out the token for privacy) :
[Wed Dec 12 11:42:00 2012] [error] [client 10.161.6.177] [APNS] push successful! ::: aa4f******44 -> {"aps":{"alert":{"body":"\\u300casdfasdf\\u300d","action-loc-key":"OK"},"badge":4,"sound":"chime"}} (134 bytes)
Is there any way I can get help on this problem?
Or is there anybody who is having the same problem??
Please help! I am getting complaints from some users on this....