Delivering your Pass via a web link (Medium)
You can deliver a Pass to your users by linking to it from your website, for instance, from a confirmation page.
Getting ready
You will need access to your own web server, or shared hosting space with FTP access. The following instructions are for an Apache web server. Mac OSX does come with an Apache web server built in, which can be used. This used to be available under the Sharing menu in System Preferences, however since OSX 10.8 it can only be activated by the command line. You can run the following command from the Terminal, to start the web server:
sudoapachectl start
The root for this server can be found at /Library/WebServer/Documents/
.
The files we will create can be downloaded from the following location:
How to do it…
Save the following MIME type instruction into a file named
htaccess
:AddType application/vnd.apple.pkpass pkpass
Create an HTML page linking to a Pass, shown as follows, and save it as
index.html
:Get your employee pass <a href='Pass-Example-Generic.pkpass'>HERE</a>
Upload your
htaccess
file, theindex.html
file and the Pass file to a publicly accessible directory on your web sever. If you are running your web server locally, place these files within the web server's root folder.Rename the
htaccess
file to.htaccess
. (The file may disappear, as files starting with a.
are treated as hidden files.)With Mobile Safari on your iPhone, visit the URL for the
index.html
file on your web server.Follow the link to your Pass and Mobile Safari will display the Pass so it can be added to Passbook.
How it works…
For the Safari or Mobile Safari browser to understand a Pass file and display it to the user, your Web server needs to present the files with the MIME type of application/vnd.apple.pkpass
.
The .htaccess
file tells the web server how to treat files in the folder in which resides. In this case it is instructing the web server to inform any visiting web browser that files with the file extension pkpass
are to be treated as Passes. The .htaccess
must be placed in each folder that contains a Pass.
Only users of a browser that supports this MIME type will be present with the Pass dialog, the rest will be prompted to download the Pass. While Safari and Mobile Safari support Passes, other third party browsers may not. However, the current versions of Chrome on iOS and the in-app browser from the Facebook app do support Pass display.
There's more…
If you wish to add server-wide support of the Pass MIME type, you can add an entry to your Apache web server's mimes.type
file, this is located in the conf
directory. Open up the file in a text editor and add the following line in the correct alphabetical position:
application/vnd.apple.pkpass pkpass
You will need to restart the server for this to take effect.