I am trying to send a push notification in iOS application via php. So the iOS developer give me the pem file. I requested the hosting server to open gateway.sandbox.push.apple.com:2195
and they have opened the port. But when I am trying to send push notification, I am getting the following error. My code looks like
$deviceToken='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$passphrase="";
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', '/home/sitename/public_html/push/ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$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 connect amarnew: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
Getting the following error
Failed to connect amarnew: 0
So I tried the connection to apple via telnet, that result is
root@uio3-i [~]# telnet gateway.sandbox.push.apple.com 2195
Trying XX.XXX.XXX.XX...
Connected to gateway.sandbox.push.apple.com.
Escape character is '^]'.
^\q
^]
telnet> q
Connection closed.
root@uio3-i [~]#
As I am new to this, I just stucked here. Please any one help me
Thanks in advance