Your out-of-the-box solution to start serving Wallet Passes in your Ruby On Rails application.
Do you have a QRCode or a Barcode anywhere in your app that you want to distribute as Wallet Pass, compatible for iOS and Android? Look no further!
This gem provides everything necessary to distribute Wallet Passes in pkpass format, and gives you all the steps to follow for what we cannot provide.
- A (not yet) fancy dashboard to manage your passes, registered devices and logs.
- All API endpoints to serve your passes: create, register, update, unregister, etc...
- All necessary ActiveRecord models.
- A BasePass model that you can extend to create your own passes.
- Some helpers to generate the necessary URLs, so that you can include them in the emails.
- Examples for everything.
We don't provide (yet):
- Full tests coverage: we are working on it!
- A fancy dashboard: our dashboard is really really simple right now. Pull requests are welcome!
- Push notifications: this is the most wanted feature I believe. Pull requests are welcome!
- Google Wallet integration: we use https://walletpasses.io/ on Android to read .pkpass format.
Add this line to your application's Gemfile:
And then execute:
$ bundle install
Or install it yourself as:
$ gem install passkit
Run the initializer:
$ rails g passkit:install
that will generate the migrations and the initializer file.
Mount the engine in your
mount Passkit::Engine => '/passkit', as: 'passkit'
Setup environment variables
If you followed the installation steps, you already saw that Passkit provides you the tables and ActiveRecord models, and also an engine with the necessary APIs already implemented.
Now is your turn. Before proceeding, you need to set these ENV variables:
We have a specific guide on how to get all these, please follow it. You cannot start using this library without these variables set, and we cannot do the work for you.
If you followed the installation steps and you have the ENV variables set, we can start looking at what is provided for you.
http://localhost:3000/passkit/dashboard/previews and you will see a first
ExampleStoreCard available for download.
You can click on the button and you will obtain a
.pkpass file that you can simply open or install on your phone.
The dashboard has also a view for logs, and a view for emitted passes.
By default the dashboard is protected with basic auth. Set the credentials using these ENV variables:
You can also change the authentication method used (see example below for Devise):
# config/passkit.rb Passkit.configure do |config| config.authenticate_dashboard_with do warden.authenticate! scope: :user ## redirect_to main_app.root_path unless warden.user.admin? # if you want to check a specific role end end
If you use mailer previews, you can create the following file in
module Passkit class ExampleMailerPreview < ActionMailer::Preview def example_email Passkit::ExampleMailer.example_email end end end
and head to
http://localhost:3000/rails/mailers/ to see an example of email with links to download the Wallet Pass.
Please check the source code of ExampleMailer to see how to distribute your own Wallet Passes.
Please check the source code of the ExampleStoreCard to see how to create your own Wallet Passes.
Again, looking at these examples, is the easiest way to get started.
Create your own Wallet Pass
You can create your own Wallet Passes by creating a new class that inherits from
defining the methods that you want to override.
You can define colors, fields and texts. You can also define the logo and the background image.
You should place the images in a 'private/passkit/<your_downcased_passname>' folder. There is a dummy app in the gem that you can use to check how to create your own Wallet Passes.
Serve your Wallet Pass
Use the Passkit::UrlGenerator to generate the URL to serve your Wallet Pass. You can initialize it with:
and then use
.ios to get the URL to serve the Wallet Pass.
Again, check the example mailer included in the gem to see how to use it.
- On Mac, open the
Console.appto view the errors.
- Check the logs on http://localhost:3000/passkit/logs
- In case of error "The passTypeIdentifier or teamIdentifier provided may not match your certificate, or the certificate trust chain could not be verified." the certificate (p12) might be expired.
After checking out the repo, run
bin/setup to install dependencies. Then, run
rake test to run the tests. You can also run
bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install. To release a new version, update the version number in
version.rb, and then run
bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the
.gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/coorasse/passkit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Passkit project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.