PassEncoder

public class PassEncoder

A class used to encode PassKit passes.

Note

This class can only be used once. After running encode(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

    passData

    The 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

    passDataURL

    The 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) -> Bool

    Parameters

    url

    The URL of the file to add to the pass.

    customName

    A 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) -> Bool

    Parameters

    name

    The name of the file to add in the pass’s directory.

    data

    The 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

    signingInfo

    The 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.