/xl-passbook-ruby

Primary LanguageRubyApache License 2.0Apache-2.0

Passbook-Ruby

Build Status

Passbook is an app distributed on iOS6. This is an implementation for management and signing of pkpasses for your Rails application. The management of templates and all the other data is done in-memory. This gem does not write to the filesystem. This results in a speed boost.

Quick Start Video:
http://www.youtube.com/watch?v=GeWFk1FvEKc

Usage

Install

gem 'passbook-ruby'
bundle

P12 certificate

This the first of 2 certificates you need to sign a pkpass. Apple has a step-by-step for most of it. You can pick up from step 7. Alternatively, you can follow all of my steps:

  1. Go to iOS Provisioning Portal (you need to login or register)
  • Click on "Pass Type IDs" on the left side menu
  • Click on "New Pass Type ID" and fill in the 2 fields
  • After you come back to the listing of pass type ids, click on "Configure" link next to the one you created
  • Click on Configure button and follow the instructions in the wizard
  • Once you download the pass.cer, double-click to install
  • In the "Keychain Access" tool right-click on Pass Type ID: <you.pass.id> and click "Export "Pass Type .....""
  • Change "File Format" to "Personal Information Exchange(.p12)" and save (preferably to Rails.root/data/certificates/)
  • The password you enter during the saving process will go into the initializer ("Run Generator" step)

WWDR Certificate

Second certificate you need to sign a pkpass

  1. Download http://developer.apple.com/certificationauthority/AppleWWDRCA.cer
  • Double-click to install
  • In the "Keychain Access" tool right-click on "Apple Worldwide Developer Relations Certification Authority" and click on Export "Apple....
  • Change "File Format" to "Privacy Enhanced Mail (.pem)" and save it (preferably to Rails.root/data/certificates/)

Run generators

All the parameters are optional. You can just edit the initializer later

   rails g passbook:config [wwdr_certificate_path]

That creates an initializer and a migration. Don't forget to put the WWDR certificate into the path now, if you used the defaults.

After that, let's create a pkpass model (ie. ticket). I would strongly advise specifying model_name, pass_type_id and tead_id at this points.

   rails g passbook:pkpass [model_name] [pass_type_id] [team_id] [cert_path] [cert_password]

This will generate a model, a migration, an initializer, a route and a sample pass (to data/templates/your_pass_type_id). Make sure to add your .p12 into the path now if you use the defaults. Also, if you didn't set the password for the cert in the above command, make sure you change the default to your password in config/initializers/passbook_#{model_name}.rb.

   rake db:migrate
   rails s

and go to \passes\model_name on your iphone (make sure it is in debug mode and allows http connections)

Check out FAQs wiki section if you get in trouble

####Thank you for help: Dwayne Forde, Cody Veal, Gregory Chow, Vincent Lee, Hussam Sheikh, Tanzeeb Khalili, Vincent Coste

####License

Except as otherwise noted, the Passbook-Ruby gem is licensed under the Apache License, Version 2.0