Book Image

Instant Passbook App Development for iOS How-to

By : Keith D. Moon
Book Image

Instant Passbook App Development for iOS How-to

By: Keith D. Moon

Overview of this book

With iOS 6, Apple introduced the Passbook app as a central digital wallet for all the store cards, coupons, boarding passes, and event tickets that have become a popular feature of apps. The passes in Passbook can be tied to relevant locations and times, providing additional visibility for your brand or service. Instant Passbook App Development for iOS How-to is a step-by-step walkthrough of how to create, customize, deliver, and update a pass for Passbook, the newest and most exciting iOS 6 feature. With sample code and clear instructions you will be guided through the process and helped to avoid the pitfalls. Instant Passbook App Development for iOS How-to helps you understand Apple's Passbook feature, leading you through creating and distributing your first pass. Clear step-by-step instructions, along with sample code and resources, will get you up and running so you can integrate Passbook into your app or service. With this book you will learn how to create, customize, sign, deliver, and update your Passbook pass, with the help of sample code and clear instructions.
Table of Contents (7 chapters)

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:

http://passkit.pro/apache-mime-type

How to do it…

  1. Save the following MIME type instruction into a file named htaccess:

    AddType application/vnd.apple.pkpass pkpass
  2. 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>
  3. Upload your htaccess file, the index.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.

  4. Rename the htaccess file to .htaccess. (The file may disappear, as files starting with a . are treated as hidden files.)

  5. With Mobile Safari on your iPhone, visit the URL for the index.html file on your web server.

  6. 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.