SBSDKNFCPassportReader


@interface SBSDKNFCPassportReader : NSObject

A class for reading out the data of a passports Near Field Communication (NFC) chip.

Notes:

Requires

Requires iOS 13.0+
  • Your app needs to add the “Near Field Communication Tag Reading” entitlement
  • Your apps info.plist needs to define the passport nfc application ID. To do so add the following entry: “com.apple.developer.nfc.readersession.iso7816.select-identifiers” and as the first element add the passport application ID “A0000002471001”
  • Declaration

    Objective-C

    + (BOOL)isPassportReadingAvailable;

    Swift

    class func isPassportReadingAvailable() -> Bool

    Return Value

    YES, if passport NFC reading is available on the system, NO otherwise.

  • Not available.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Not available.

    Declaration

    Objective-C

    + (nonnull instancetype)new;
  • Designated initializer.

    Declaration

    Objective-C

    - (nonnull instancetype)
        initWithPassportNumber:(nonnull NSString *)passportNumber
                     birthDate:(nonnull NSDate *)birthDate
                expirationDate:(nonnull NSDate *)expirationDate
                initialMessage:(nullable NSString *)messsage
                      delegate:(nonnull id<SBSDKPassportReaderDelegate>)delegate;

    Swift

    init(passportNumber: String, birthDate: Date, expirationDate: Date, initialMessage messsage: String?, delegate: SBSDKPassportReaderDelegate)

    Parameters

    passportNumber

    The passports alphanumerical ID, as printed on the passport.

    birthDate

    The passport holders birth date.

    expirationDate

    The passports expiry date

    messsage

    The initial message being shown on the NFC-scanning UI when NFC reading starts.

    delegate

    The delegate of the passport reader.

    Return Value

    A newly initialized and ready to use instance of SBSDKNFCPassportReader.

  • Sets the message being displayed on the NFC-scanning UI.

    Note: Repeated message changes may not be reflected in the UI due to the asynchronous updating. This is a restriction of the underlying Apple API.

    Declaration

    Objective-C

    - (void)setMessage:(nonnull NSString *)message;

    Swift

    func setMessage(_ message: String)

    Parameters

    message

    The message to be displayed.

  • Enumerates all available data group types on the passports NFC chip and returns them to the completion handler.

    Note: Not all available data groups are accessible/readable with the basic authentication that we are allowed to use. Most often only DG1 and DG2 are accessible.

    Declaration

    Objective-C

    - (void)enumerateDatagroups:
        (nonnull void (^)(NSArray<SBSDKNFCDatagroupType *> *_Nonnull))completion;

    Swift

    func enumerateDatagroups(_ completion: @escaping ([String]) -> Void)

    Parameters

    completion

    The completion handler called when the operation has finished. Passes an array of available data group types.

  • Downloads and parses the specified data groups.

    Declaration

    Objective-C

    - (void)downloadDatagroupsOfType:
                (nonnull NSArray<SBSDKNFCDatagroupType *> *)types
        shouldIgnoreUnavailableGroups:(BOOL)shouldIgnoreUnavailableGroups
                           completion:(nonnull void (^)(NSArray<SBSDKNFCDatagroup *>
                                                            *_Nonnull))completion;

    Swift

    func downloadDatagroups(ofType types: [String], shouldIgnoreUnavailableGroups: Bool, completion: @escaping ([SBSDKNFCDatagroup]) -> Void)

    Parameters

    types

    An array of data group types the receiver should read and parse. Usually this is only DG1 and DG2.

    shouldIgnoreUnavailableGroups

    If set to NO, then the state when some of requested groups will be missing or unavailable will be treated as an error state and nothing will return. If set to YES, the method will just return available groups, ignoring unavailable.

    completion

    The completion handler that is called when reading and parsing of the specified data groups has finished. The completion handler is called passing an array of readily parsed data group objects.

  • Downloads and parses the specified data groups. Unavailable data groups are ignored.

    Declaration

    Objective-C

    - (void)
        downloadDatagroupsOfType:(nonnull NSArray<SBSDKNFCDatagroupType *> *)types
                      completion:
                          (nonnull void (^)(NSArray<SBSDKNFCDatagroup *> *_Nonnull))
                              completion;

    Swift

    func downloadDatagroups(ofType types: [String], completion: @escaping ([SBSDKNFCDatagroup]) -> Void)

    Parameters

    types

    An array of data group types the receiver should read and parse. Usually this is only DG1 and DG2.

    completion

    The completion handler that is called when reading and parsing of the specified data groups has finished. The completion handler is called passing an array of readily parsed data group objects.