PassEncoder
public class PassEncoder
A class used to encode PassKit passes.
Note
This class can only be used once. After runningencode(signingInfo:, completion:) once, it will throw a fatal error.
-
Intiialize the encoder with the provided pass.json data. Will return nil if an error occurs.
Declaration
Swift
public init?(passData: [String : Any])Parameters
passDataThe data to use for pass.json
-
Intiialize the encoder with the provided pass.json URL. Will return nil if an error occurs.
Declaration
Swift
convenience public init?(passDataURL: URL)Parameters
passDataURLThe URL pass.json is located at.
-
Called when deinitializing the encoder. Used to remove our temporary directory.
Declaration
Swift
deinit
-
Add the file at the provided URL to the pass.
Declaration
Swift
public func addFile(from url: URL, customName: String? = nil) -> BoolParameters
urlThe URL of the file to add to the pass.
customNameA custom name to add the file with.
Return Value
Whether or not the operation was successful.
-
Add a file with the provided data to the pass with the provided name.
Declaration
Swift
public func addFile(named name: String, from data: Data) -> BoolParameters
nameThe name of the file to add in the pass’s directory.
dataThe data to create the file with.
Return Value
Whether or not the operation was successful.
-
Perform the encoding process and return the signed and archived pass as
Data.Declaration
Swift
public func encode(signingInfo: PassSigner.SigningInfo?) -> Data?Parameters
signingInfoThe certificate and password to sign the pass with. If left out, the pass will not be signed.
Return Value
The pass’s data, if successful.
View on GitHub
PassEncoder Class Reference