I just come to know that iOS 13 have changed Push notification device token and Payload. I have update App and published it. Now, We have server in Php, We send both alert and silent notification to the users. I have gone through "https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns" Apple Documentation, but I am still not able to understand how can I pass new headers in payload.
Here is the my Php Script.
<?php
// Put your device token here (without spaces):
$deviceToken = 'deviceToken';
// Put your private key's passphrase here:
$passphrase = 'dummyPassword';
////////////////////////////////////////////////////////////////////////////////
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'pushcert.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
//stream_context_set_option($ctx, 'ssl', 'cafile', 'entrust_2048_ca.cer');
// Open a connection to the APNS server
$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: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
$body['aps'] = array(
'content-available' => '1',
'type' => 'message',
'msg' => 'We detected a failure when sending a message.'
);
// Encode the payload as JSON
$payload = json_encode($body);
echo "\njson::::\n";
print_r ($payload);
// 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);
Can anyone have any example, tutorial or PHP Script so I can create payload for Apple Push notification. Any help will be appreciated.