-
-
Save samvermette/759564 to your computer and use it in GitHub Desktop.
<?php | |
$apnsHost = 'gateway.sandbox.push.apple.com'; | |
$apnsCert = 'apns-dev.pem'; | |
$apnsPort = 2195; | |
$streamContext = stream_context_create(); | |
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert); | |
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext); | |
$payload['aps'] = array('alert' => 'Oh hai!', 'badge' => 1, 'sound' => 'default'); | |
$output = json_encode($payload); | |
$token = pack('H*', str_replace(' ', '', $token)) | |
$apnsMessage = chr(0) . chr(0) . chr(32) . $token . chr(0) . chr(strlen($output)) . $output; | |
fwrite($apns, $apnsMessage); | |
socket_close($apns); | |
fclose($apns); |
I am getting same errors as you @bhavin-chauhan. Did you manage to get this issue fixed?
Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection refused) in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 17
Warning: pack(): Type H: illegal hex digit h in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 34
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 35
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 42
Warning: Cannot modify header information - headers already sent by (output started at /home/mandin/public_html/vadmin2/send_broadcast_dev.php:42) in /home/mandin/public_html/vadmin2/common.php on line 977
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 35
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 42
Can anyone help please???
I am getting same errors as you @bhavin-chauhan. Did you manage to get this issue fixed?
Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection refused) in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 17
Warning: pack(): Type H: illegal hex digit h in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 34Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 35
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 42
Warning: Cannot modify header information - headers already sent by (output started at /home/mandin/public_html/vadmin2/send_broadcast_dev.php:42) in /home/mandin/public_html/vadmin2/common.php on line 977
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 35
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/mandin/public_html/vadmin2/send_broadcast_dev.php on line 42
Can anyone help please???
My Server not allow me to open APN Port number, So Finally I've Used Firebase service for that task. It's easy to use and both android, iOS token can easily work now. Let me know if you need any help from my side.
Thanks!
Bhavin
i am getting fwrite(): send of 92 bytes failed with errno=10053 An established connection was aborted by the software in your host machine. this error please help me.