Reputation: 2510
I was making a pass in php with expiredate parameter.I want to update pass using Apple push notification. According to the Passbook docs you need to use the Apple Push Notification Service to trigger a pull from the iOS device in order to update the Passbook.
Upvotes: 3
Views: 3691
Reputation: 2017
This is my PHP codes to push notification to APNS. You can refer.
$apnsHost = 'gateway.push.apple.com';
$apnsPort = 2195;
$apnsCert = base_path('certificates.pem');
$push_token = 'device token';
$passIdentify = 'pass indentify';
$payload = '{}';
$msg = chr(0) . pack('n', 32) . pack('H*', $push_token) . pack('n', strlen($payload)) . $payload . pack('n', strlen($passIdentify)) . $passIdentify;
$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);
fwrite($apns, $msg);
@socket_close($apns);
fclose($apns);
The certificates.pem is the same certificate you use to sign your pass in .p12 extension. So you need to export it to .pem by using the following codes
$ cd ~/Desktop
$ openssl pkcs12 -in WenderCastPush.p12 -out WenderCastPush.pem -nodes -clcerts
According to this tutorial https://www.raywenderlich.com/123862/push-notifications-tutorial#comments.
Upvotes: 1