This is inspired by Passifier which i couldn't get to run with p12 signing. So here is my take on iOS Passbook passes. It's used here: https://chefcards.herokuapp.com
Add this line to your application's Gemfile:
gem 'power-passbook', github: 'max-power/passbook'
And then execute:
$ bundle
First setup Signing:
signer = Passbook::Authority.new(File.read("/path/to/certificate.p12"), "secret-password")
The basic usage is:
pass = Passbook::PKPass.new(pass_specifications, pass_assets, signer)
pass.to_file("my/path/to/the/pass.pkpass")
pass.to_s
pass.content_type # "application/vnd.apple.pkpass"
Pass specifications is a hash that should match the Apple Passbook Format Reference.
pass_specifications = {
"formatVersion" => 1,
"passTypeIdentifier" => "pass.com.flycheap.boardingpass",
"teamIdentifier" => "XXXXXXXX",
"organizationName" => "XXXXXXXX",
"labelColor" => "#ffffff",
"backgroundColor" => "#618d04",
"foregroundColor" => "#ffffff",
"serialNumber" => "123",
"logoText" => "Hi",
...
}
The assets parameter is a hash with filenames as keys and local or remote paths to the file as value. See the Apple Pass Design and Creation guidelines to see which files are used for the different pass types.
pass_assets = {
"background.png" => "assets/background.png",
"[email protected]" => "assets/[email protected]",
"icon.png" => "assets/icon.png",
"[email protected]" => "assets/[email protected]",
"logo.png" => "http://i.imgur.com/WLUf6.png",
"[email protected]" => "http://i.imgur.com/mOpQo.png",
"thumbnail.png" => "assets/thumbnail.png",
"[email protected]" => "assets/[email protected]"
}
There is also a very tiny (60 LOC) version available here: https://gist.github.com/max-power/9262053
- Fork it ( http://github.com/max-power/passbook/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request