Passbook is a often under utilized feature of IOS. For those who haven’t used it, Passbook is a app that comes with all phones running IOS 6 and above. Passes can be mailed, shared, retrieved from a website or delivered via a app. They also support push notifications that can update the pass along with the ability for the pass to show a notification if a user is in the proximity of certain locations or during certain times depending on the type of pass you have.
As a Rubiest you don’t have to learn Objective C or Swift to create them because passes are a zip file consisting of images, a pass.json file, a manifest and a signature file. The Passbook Ruby Gem makes this fairly straight forward. Recently we released version 0.4.0 of the gem, so what’s new?
Making It Easier To Get Started
While the gem makes it easy to get your gem signed and out the door, up until this release you needed to write a program or use IRB to generate your pass. There were also no templates to get you kick started. Well, technically there was in 0.3.x but we didn’t tell anyone about it. Now we are officially releasing this functionality. To get started you will need to install the gem.
Next, create a directory for your passbook, go to the directory and then generate the passbook template.
You will still need to go through the steps of setting up your pass name, certificates etc.. This article will show you how to do that. Then you can add content to your pass etc.. Once you have done this there is another command line utility that allows you to build your pass via.
You will see a .pkpass file in your directory. To test out your new pass you can drop it on your IOS simulator or mail it to your phone.
Allowing Different Certificates For Different Passes
One limitation of the Passbook gem has been that you could only create one set of certificates for a program using the gem. For many applications that is all that is necessary, but some apps might need to have different certificates for different passes etc.. Now you can via the Signer class.
When you create a PKPass object, by default if you don’t pass it a Signer class it uses your Passbook application certificate configuration settings. If you want to use a different set of certificates you simply create a Signer class and pass in the references to the certificates you want to use.
pk_pass = Passbook::PKPass.new your_json_data, signer
We have been using Passbook in production but are always looking for ways to make it better. If there is a feature that you need please put in a feature request or send us a pull request. You can find the project here.