I have an iOS app with rss feeds, it has iOS push notification service , the push notifications works fine for some devices (the previous devices ) , but the new or last devices are not receive the push notifications for this app at all . I think the error is in my php script , but I don't know how I can solve it , the host of my website that connecting with my app is BlueHost.com .
-Error log is :
[08-Aug-2013 11:00:14 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /home3/basiphon/public_html/Push.php on line 56
[08-Aug-2013 11:15:24 America/Denver] PHP Warning: stream_socket_client(): SSL: crypto enabling timeout in /home3/basiphon/public_html/Push.php on line 56
[08-Aug-2013 11:15:24 America/Denver] PHP Warning: stream_socket_client(): Failed to enable crypto in /home3/basiphon/public_html/Push.php on line 56
[08-Aug-2013 11:15:24 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /home3/basiphon/public_html/Push.php on line 56
[08-Aug-2013 11:30:33 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Connection timed out) in /home3/basiphon/public_html/Push.php on line 56
[08-Aug-2013 11:46:39 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Connection timed out) in /home3/basiphon/public_html/Push.php on line 56
-My PHP script
// Open a connection to the APNS server
$fp = stream_socket_client(
$url, $err,
$errstr, 2, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
{
echo 'Message successfully delivered111' . PHP_EOL;
$query_update="update wp_apns_messages set status='delivered',delivery=NOW() where pid='$pid'";
$res_update=mysql_query($query_update) or die(mysql_error());
}
// Close the connection to the server
fclose($fp);
}
//echo "***";
?>
</body>
</html> </i>