and add “PassEncoder” to your target’s dependencies.
Usage
// Create our encoder
if let encoder = PassEncoder(passDataURL: directory.appendingPathComponent("pass.json")) {
// Add a nice icon
encoder.addFile(from: directory.appendingPathComponent("icon.png"))
let passData = encoder.encode(signingInfo: (certificate: URL_TO_CERT.PEM, password: CERT_PASSWORD))
// Your archived .pkpass file is in passData as Data
}
Before using the library, you’ll also need to set the Apple WWDR certificate URL, which you can read about below.
Heads up! Operations in this library are all synchronous, so it is advisable to run them on a separate OperationQueue so that they do not block your thread.
Creating and preparing your certificate
You need to repeat this step for each different passTypeId you have in your pass.json.
To take full advantage of the package, check out the documentation and see all of the methods and variables that are made available to you.
Contributing
Feel free to contribute to the source code of PassEncoder to make it something even better! Just try to adhere to the general coding style throughout, to make it as readable as possible.
If you find an issue in the code or while using it, create an issue. If you can, you’re encouraged to contribute and make a pull request.
License
This project is licensed under the MIT license. Please make sure you comply with its terms while using it in any way.
PassEncoder
Apple Wallet (formerly Passbook) pass encoding and signing in Swift.
Features
Data
easilyRequirements
Installation
Swift Package Manager
Add the following line to your dependencies section of
Package.swift
:and add “PassEncoder” to your target’s dependencies.
Usage
Before using the library, you’ll also need to set the Apple WWDR certificate URL, which you can read about below.
Creating and preparing your certificate
You need to repeat this step for each different
passTypeId
you have in yourpass.json
.Certificates.p12
.openssl pkcs12 -in Certificates.p12 -out PassCert.pem
.PassCert.pem
!You’ll also need to download the Apple Worldwide Developer Relations Intermediate Certificate - G4 file to sign passes.
Download the intermediate certificate from here.
Import it into Keychain Access (double click it).
Find it in Keychain Access, and export it as a .pem file.
Set the
PassSigner
‘s WWDR URL to it in your code.Documentation
To take full advantage of the package, check out the documentation and see all of the methods and variables that are made available to you.
Contributing
Feel free to contribute to the source code of PassEncoder to make it something even better! Just try to adhere to the general coding style throughout, to make it as readable as possible.
If you find an issue in the code or while using it, create an issue. If you can, you’re encouraged to contribute and make a pull request.
License
This project is licensed under the MIT license. Please make sure you comply with its terms while using it in any way.
Links