Posts

Post not yet marked as solved
0 Replies
528 Views
Earlier we set up server side php code for push notification and it worked fine and receive push notification. but now the push notification showing successfully delivered but not receiving in the device. With the help of some forum I see that Apple now change ssl://gateway.sandbox.push.apple.com:2195 to ssl://api.sandbox.push.apple.com:443. But still facing same issue. I add my php file here. Please have a look and help me out there. $deviceToken = '6ec025aff884d7b9ab0da0d8fe57e471016f9f4a444fe6b0283fcc799c9ae978'; $passphrase = '123456'; $message = 'My first push notification!'; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'APNS_Live.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); // Open a connection to the APNS server $fp = stream_socket_client( 'ssl://api.sandbox.push.apple.com:443', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); if (!$fp) exit("Failed to connect: $err $errstr" . PHP_EOL); echo 'Connected to APNS' . PHP_EOL; // Create the payload body $body['aps'] = array( 'alert' => $message, 'sound' => 'default' ); // Encode the payload as JSON $payload = json_encode($body); // 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 delivered' . PHP_EOL; // Close the connection to the server fclose($fp); ?> Thanks Jasim
Posted Last updated
.