Contents

init(delegate:queue:)

Creates a new session instance for processing NFC payment tags.

Declaration

@nonobjc convenience init(delegate: any NFCTagReaderSessionDelegate, queue: DispatchQueue? = nil)

Parameters

  • delegate:

    A delegate that receives callbacks about discovered tags and session life cycle events. The session holds a weak reference to the delegate.

  • queue:

    A dispatch queue on which to perform delegate callbacks. The session object retains the provided dispatch queue. If this value is nil, the framework creates an internal serial dispatch queue for the session.

Discussion

Creating a session requires that your app have the Near Field Communication Tag Reader Session Formats Entitlement entitlement; if it’s missing, your delegate receives the callback tagReaderSession(_:didInvalidateWithError:) with the error NFCReaderError.Code.readerErrorSecurityViolation. Additionally, the app’s information property list must contain a non-empty usage description string. If it’s absent, the delegate doesn’t receive tag-discovery callbacks.

When the session discovers an ISO 7816-compatible tag, the session performs a SELECT command for each application identifier provided in ISO7816 application identifiers for NFC Tag Reader Session. The SELECT command searches for the identifiers in the order in which they appear in the array. The session calls the tagReaderSession(_:didDetect:) delegate method after the first successful SELECT command. The initialSelectedAID property of the found tag contains the selected identifier.

See Also

Creating a tag reader session