PKPass Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/PassKit.framework
Availability
Available in iOS 6.0 and later.
Companion guide
Declared in
PKPass.h

Overview

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.

Tasks

Working with Passes

Identifying a Pass

Displaying a Pass

Properties

authenticationToken

The token used to authenticate with the web service. (read-only)

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

An app that uses its own protocol for communicating with your server about passes can use this. The app can include the authentication token in its requests to show that they are coming from a device that has a copy of the pass, and not from an attacker.

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

icon

The pass’s icon. (read-only)

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

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

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

localizedDescription

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

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

You can use this property to provide accessibility information for a UI element that represents a pass, such as a cell in a table view.

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

localizedName

The localized description of the pass’s kind. (read-only)

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

You can use this property to provide accessibility information for a UI element that represents a pass, such as a cell in a table view.

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

organizationName

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

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

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

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

passTypeIdentifier

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

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

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

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

passURL

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

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

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

relevantDate

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

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

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

serialNumber

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

@property(nonatomic, copy, readonly) NSString *serialNumber
Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

userInfo

Developer-specific custom data. (read-only)

@property(nonatomic, copy, readonly) NSDictionary *userInfo
Availability
  • Available in iOS 7.0 and later.
Declared In
PKPass.h

webServiceURL

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

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

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

Instance Methods

initWithData:error:

Initializes and returns an instance of the class.

- (id)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.

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

localizedValueForFieldKey:

Returns the localized value for specified field of the pass.

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

Availability
  • Available in iOS 6.0 and later.
Declared In
PKPass.h

Constants

Pass Kit Error Domain

Error domain for Pass Kit errors.

NSString *const PKPassKitErrorDomain;
Constants
PKPassKitErrorDomain

Error domain for PassKit errors.

Available in iOS 6.0 and later.

Declared in PKPass.h.

Pass Kit Errors

Errors used by the Pass Kit framework.

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

Unknown error.

Available in iOS 6.0 and later.

Declared in PKPass.h.

PKInvalidDataError

Invalid pass data.

Available in iOS 6.0 and later.

Declared in PKPass.h.

PKUnsupportedVersionError

Unsupported pass version.

Available in iOS 6.0 and later.

Declared in PKPass.h.

PKInvalidSignature

Pass signature is invalid.

For example, the pass type identifier in the certificate and the pass may not match, or the certificate may have expired or been revoked.

Available in iOS 6.0 and later.

Declared in PKPass.h.