This class provides the functionality to create an Pass for Passbook in Apple's iOS 6 and newer on-the-fly. It creates, signs and packages the Pass as a .pkpass file according to Apple's documentation.
- PHP 5.4
- PHP ZIP Support (May be installed by default)
- Access to filesystem (Script must be able to create temporary folders)
Run: $ composer require pkpass/pkpass
or add to your composer.json: "pkpass/pkpass": "dev-master"
Require PKPass.php file in your php files require('PKPass.php');
Please take a look at the example.php file for example usage. For more info on the JSON for the pass and how to style it, take a look at the docs at developers.apple.com. Another helpful PDF
Demo:
- Simple example (example.php): http://apps.tomttb.com/pkpass/example.php
- Full example (full_sample/index.php): http://apps.tomttb.com/pkpass/full_sample
Note: this example shows how to support localized keys. - Starbucks example (starbucks_sample/index.php): http://apps.tomttb.com/pkpass/starbucks_sample
- Go to the iOS Provisioning portal
- Create a new Pass Type ID
- Request the certificate like shown
- Download the .cer file and drag it into Keychain Access
- Right click the certificate in Keychain Access and choose
Export 'pass.<id>'…
- Choose a password and export the file to a folder
- Request the Pass certificate (
.p12
) and upload it to your server - Set the correct path and password on line 6 and 7
- Download and import your WWDR Intermediate certificate to Keychain, export as
.pem
and set the correct path on line 8 - Change the
passTypeIdentifier
andteamIndentifier
to the correct values, which can be found on the iOS Provisioning portal after clicking on 'Configure' next to the Pass ID, on line 15 and 17
After completing these steps, you should be ready to go. Upload all the files to your server and navigate to the address of the example.php file on your iPhone.
Please read the instructions above and consult the Passbook Documentation before submitting tickets or requesting support.
Email me at tom [at] tomttb.com or tweet me @tschoffelen.
Like my work? Consider giving a small donation.