Answer the question
In order to leave comments, you need to log in
What certificate is used to send web push messages via APNS?
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $certDir);
openssl s_client -connect gateway.push.apple.com:2195 -cert cert.pem
$certDir = 'cert.pem';
$address = 'gateway.push.apple.com:2195';
$deviceToken = 'D1BF307920AEA35AA1E2C3F4B38863FC801F08EEC9BA00FABDDBCFF3C517DAB6';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $certDir);
stream_context_set_option($ctx, 'ssl', 'passphrase', '***');
$socketClient = stream_socket_client(
$address,
$errno,
$errstr,
60,
STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT,
$ctx
);
var_dump($errstr);
$payload = array(
'aps' => array(
'alert' => array(
'title' => 'Foo',
'body' => 'bar',
'action' => 'view',
),
)
);
$encodedPayload = json_encode($payload);
// $binaryMessage = chr(0).
// chr(0).
// chr(32).
// pack('H*', $deviceToken).
// chr(0).chr(strlen($encodedPayload)).
// $encodedPayload;
$binaryMessage = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($encodedPayload)) .$encodedPayload;
$result = fwrite($socketClient, $binaryMessage, strlen($binaryMessage));
var_dump($result);
while(!feof($socketClient)) {
var_dump(fgets($socketClient,64));
}
fclose($socketClient);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question