Elixir library to create Apple Wallet (.pkpass) files (Apple Wallet has previously been known as Passbook in iOS 6 to iOS 8).
See the Wallet Topic Page and the Wallet Developer Guide for more information about Apple Wallet.
This package can be installed by adding passbook
to your list of dependencies in mix.exs
:
def deps do
[
{:passbook, "~> 0.1.8"}
]
end
- Get a Pass Type Id
- Visit the iOS Provisioning Portal -> Pass Type IDs -> New Pass Type ID
- Select pass type id -> Configure (Follow steps and download generated pass.cer file)
- Use Keychain tool to export a Certificates.p12 file (need Apple Root Certificate installed)
- Make sure you have open ssl installed, and generate the necessary certificate
$ openssl pkcs12 -in "Certificates.p12" -clcerts -nokeys -out certificate.pem
- Generate the key.pem
$ openssl pkcs12 -in "Certificates.p12" -nocerts -out key.pem
You will be asked for an export password (or export phrase), which you need to use when generating the .pkpass
files.
iex> Passbook.generate(%Passbook.Pass{
background_color: "rgb(23, 187, 82)",
foreground_color: "rgb(100, 10, 110)",
barcode: %Passbook.LowerLevel.Barcode{
format: :qr,
alt_text: "1234",
message: "qr-code-content"
},
description: "This is a pass description",
organization_name: "My Organization",
pass_type_identifier: "123",
serial_number: "serial-number-123",
team_identifier: "team-identifier",
generic: %Passbook.PassStructure{
transit_type: :train,
primary_fields: [
%Passbook.LowerLevel.Field{
key: "my-key",
value: "my-value"
}
]
}}, ["icon.png": "path/to/file.png", "[email protected]": "path/to/file.png"], "path/to/wwdr.pem", "path/to/certificate.pem", "path/to/key.pem", "password", target_path: System.tmp_dir!(), pass_name: "mypass")
{:ok, "path/to/generated/mypass.pkpass"}