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.
Asked
Active
Viewed 3,044 times
3
-
If you are looking for copy/paste code then you have come to the wrong place. The documents are very clear, I suggest you try for yourself and come back with a specific programming question if you get stuck. – PassKit Sep 08 '16 at 11:08
-
What are you asking? Your statement "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." is correct. – PassKit Sep 08 '16 at 11:41
-
There are also many answers already that address your question. http://stackoverflow.com/questions/15877496/how-to-make-a-push-notification-for-a-pass, http://stackoverflow.com/questions/34310956/update-passes-of-passbook. – PassKit Sep 08 '16 at 11:43
-
yes, but i am confuse the notification will automaticaly update the pass or it just to notify user to update pass and the rest things doing on iOS end. – vipin Sep 08 '16 at 11:51
-
The notification will trigger the phone to call your WebServiceURL which must return a list of serial numbers that require updating, then the phone will issue a second request for the updated pass and you server must return the compiled bundle. As mentioned, the [update documentation](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/PassKit_PG/Updating.html#//apple_ref/doc/uid/TP40012195-CH5-SW1) and [web service documentation](https://developer.apple.com/library/ios/documentation/PassKit/Reference/PassKit_WebService/WebService.html) is very clear. – PassKit Sep 08 '16 at 11:53
1 Answers
1
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.

Hoang Trung
- 1,979
- 1
- 21
- 33
-
is it currently working on your server and updating passes via push? Because I've tried this and it is not working on my side. Any suggestions? – tmw Oct 06 '16 at 22:09
-
1@tahirwaseer Sorry, this's not the correct answer. Please try this http://stackoverflow.com/questions/39849883/cant-push-notification-to-apns-to-update-my-pass-in-apple-wallet?noredirect=1#comment66998009_39849883 – Hoang Trung Oct 07 '16 at 04:38
-
Binary protocol is no longer supported for the Apple Push Notification service. Please check the link: https://developer.apple.com/news/?id=11042019a – Ajay Nov 14 '21 at 13:08