iOS Developer Library

Developer

PassKit Framework Reference PKPass Class Reference

Options
Deployment Target:

On This Page
Language:

PKPass

Conforms To


Import Statement


Swift

import PassKit

Objective-C

@import PassKit;

Availability


Available in iOS 6.0 and later.

The PKPass class represents a single pass.

The properties of this class correspond to fields of the pass. For details on what individual fields mean, see Passbook Package Format Reference.

  • Initializes and returns an instance of the class.

    Declaration

    Swift

    init!(data data: NSData!, error error: NSErrorPointer)

    Objective-C

    - (instancetype)initWithData:(NSData *)data error:(NSError **)error

    Parameters

    data

    A definition of a pass, as described in Passbook Package Format Reference.

    error

    On error, populated with a description of the error.

    Return Value

    The newly initialized instance.

    Discussion

    Errors returned via the error parameter are suitable for presentation to the user. Check the console for more detailed information.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • passType passType Property

    The pass’s type. (read-only)

    Declaration

    Swift

    var passType: PKPassType { get }

    Objective-C

    @property(nonatomic, assign, readonly) PKPassType passType

    Discussion

    For possible values, see PKPassType.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 8.0 and later.

  • For passes that represent payment cards, the underlying payment pass. (read-only)

    Declaration

    Swift

    unowned(unsafe) var paymentPass: PKPaymentPass! { get }

    Objective-C

    @property(nonatomic, assign, readonly) PKPaymentPass *paymentPass

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 8.0 and later.

  • passURL passURL Property

    The URL that opens the pass in the Passbook app. (read-only)

    Declaration

    Swift

    @NSCopying var passURL: NSURL! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSURL *passURL

    Discussion

    Open the URL that is returned by passing it as the argument of the openURL: method of UIApplication.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • The token used to authenticate update requests. (read-only)

    Declaration

    Swift

    var authenticationToken: String! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSString *authenticationToken

    Discussion

    Use this property to store an authentication token for your web service. When the device requests an updated copy of this pass, the request’s header will include this authorization token. Use this token to verify that the request is coming form a valid device and not from an unauthorized source.

    Don’t change the authentication token in an update. There is no guarantee that every copy of the pass will be updated. As a result, your service would need to continue supporting the outdated passes and authentication tokens.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • The pass’s type identifier. (read-only)

    Declaration

    Swift

    var passTypeIdentifier: String! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSString *passTypeIdentifier

    Discussion

    For information about getting a pass type identifier, see Passbook Programming Guide.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • A value that uniquely identifies the pass. (read-only)

    Declaration

    Swift

    var serialNumber: String! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSString *serialNumber

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • The URL for your web service. (read-only)

    Declaration

    Swift

    @NSCopying var webServiceURL: NSURL! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSURL *webServiceURL

    Discussion

    The web service is used to update passes. For information on the the web service protocol, see Passbook Web Service Reference.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • icon icon Property

    The pass icon. (read-only)

    Declaration

    Swift

    @NSCopying var icon: UIImage! { get }

    Objective-C

    @property(nonatomic, copy, readonly) UIImage *icon

    Discussion

    You can use this property to display a pass’s icon as part of a UI element that represents the pass, such as a cell in a table view.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • The localized name for the pass’s template. (read-only)

    Declaration

    Swift

    var localizedName: String! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSString *localizedName

    Discussion

    The pass’s template defines the pass’s basic layout. For more information on the available templates, see Pass Style Sets the Overall Visual Appearance in Passbook Programming Guide.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • The pass’s localized description. (read-only)

    Declaration

    Swift

    var localizedDescription: String! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSString *localizedDescription

    Discussion

    This property provides access to the description string from the pass’s JSON file. For more information on the JSON format, see Pass Design and Creation in Passbook Programming Guide. For information on adding localized strings to the JSON file, see Passes Support Localization.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • Returns the localized value for specified field of the pass.

    Declaration

    Swift

    func localizedValueForFieldKey(_ key: String!) -> AnyObject!

    Objective-C

    - (id)localizedValueForFieldKey:(NSString *)key

    Parameters

    key

    The field's key, as specified in the pass.

    Return Value

    The localized value for the pass’s field.

    Discussion

    If your app works with passes from arbitrary sources, such as an email client, it can’t use this method because the passes’ keys are not known ahead of time. Use the other properties of this class, such as icon and organizationName, instead.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • The name of the organization that created the pass. (read-only)

    Declaration

    Swift

    var organizationName: String! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSString *organizationName

    Discussion

    You can use this property to display information about the organization that created the pass as part of a UI element that represents the pass, such as a cell in a table view.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • The date when the pass is most likely to be needed or useful. (read-only)

    Declaration

    Swift

    @NSCopying var relevantDate: NSDate! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSDate *relevantDate

    Discussion

    You can use this property for sorting UI elements that represent passes, such as cells in a table view.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.

  • userInfo userInfo Property

    Developer-specific custom data. (read-only)

    Declaration

    Swift

    var userInfo: [NSObject : AnyObject]! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSDictionary *userInfo

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 7.0 and later.

  • Types of passes.

    Declaration

    Swift

    enum PKPassType : UInt { case Barcode case Payment case Any }

    Objective-C

    typedef enum : NSUInteger { PKPassTypeBarcode, PKPassTypePayment, PKPassTypeAny = ~0 } PKPassType;

    Constants

    • Barcode

      PKPassTypeBarcode

      Passes that represent a barcode or other information.

      Available in iOS 8.0 and later.

    • Payment

      PKPassTypePayment

      Passes that represent payment cards.

      Available in iOS 8.0 and later.

    • Any

      PKPassTypeAny

      Any type of pass.

      Available in iOS 8.0 and later.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 8.0 and later.

  • Error domain for PassKit errors.

    Declaration

    Swift

    let PKPassKitErrorDomain: String

    Objective-C

    NSString *const PKPassKitErrorDomain;

    Constants

    • PKPassKitErrorDomain

      PKPassKitErrorDomain

      Error domain for PassKit errors.

      Available in iOS 6.0 and later.

  • Errors used by the PassKit framework.

    Declaration

    Swift

    enum PKPassKitErrorCode : Int { case UnknownError case InvalidDataError case UnsupportedVersionError case InvalidSignature case NotEntitledError }

    Objective-C

    typedef NS_ENUM (NSInteger, PKPassKitErrorCode ) { PKUnknownError = -1, PKInvalidDataError = 1, PKUnsupportedVersionError, PKInvalidSignature, PKNotEntitledError }

    Constants

    • UnknownError

      PKUnknownError

      Unknown error.

      Available in iOS 6.0 and later.

    • InvalidDataError

      PKInvalidDataError

      Invalid pass data.

      Available in iOS 6.0 and later.

    • UnsupportedVersionError

      PKUnsupportedVersionError

      Unsupported pass version.

      Available in iOS 6.0 and later.

    • InvalidSignature

      PKInvalidSignature

      Invalid pass signature.

      For example, the pass type identifier in the certificate and the pass do not match, or the certificate has expired or was revoked.

      Available in iOS 6.0 and later.

    • NotEntitledError

      PKNotEntitledError

      Error caused by absence of the required entitlements for the given operation.

      Apps require appropriate entitlements to read, update or delete passes. To add these entitlements, enable the Passbook capabilities in Xcode.

      Available in iOS 6.0 and later.

    Import Statement

    Objective-C

    @import PassKit;

    Swift

    import PassKit

    Availability

    Available in iOS 6.0 and later.