Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Instant Passbook App Development for iOS How-to

You're reading from   Instant Passbook App Development for iOS How-to Create and customize a Passbook Pass with the exciting new iOS features.

Arrow left icon
Product type Paperback
Published in Jun 2013
Publisher Packt
ISBN-13 9781849697064
Length 56 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Keith D. Moon Keith D. Moon
Author Profile Icon Keith D. Moon
Keith D. Moon
Arrow right icon
View More author details
Toc

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.

You have been reading a chapter from
Instant Passbook App Development for iOS How-to
Published in: Jun 2013
Publisher: Packt
ISBN-13: 9781849697064
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image