Contents

sendMiFareCommand(commandPacket:completionHandler:)

Sends a native MIFARE command to the tag.

Declaration

func sendMiFareCommand(commandPacket command: Data, completionHandler: @escaping  @Sendable (Data, (any Error)?) -> Void)
func sendMiFareCommand(commandPacket command: Data) async throws -> Data

Parameters

  • command:

    A MIFARE command. For Ultralight commands, you must calculate a 2-byte CRC value and append it to the end of the command data.

  • completionHandler:

    A handler that the reader session invokes after the operation completes. The session calls completionHandler on the dispatch queue that you provided when creating the Nfctagreadersession object.

    The handler has the following parameters:

    response

    An Nsdata object containing the tag’s response data for the command.

    error

    nil when the operation is successful; otherwise, an Nserror object indicating that a problem occurred while communicating with the tag.

Discussion

Use this method to send commands to tags that are from the NFCMiFareFamily.ultralight, NFCMiFareFamily.plus, and NFCMiFareFamily.desfire product families.

This method supports command chaining, passing the full response composed of the individual fragments to the completionHandler.

See Also

Sending Commands