<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: -",
    "macOS: 10.10.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoTokenKit",
  "identifier" : "/documentation/CryptoTokenKit/TKSmartCard/send(ins:p1:p2:data:le:reply:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "CryptoTokenKit"
    ],
    "preciseIdentifier" : "s:So11TKSmartCardC14CryptoTokenKitE4send3ins2p12p24data2le5replyys5UInt8V_A2L10Foundation4DataVSgSiSgyAP_s6UInt16Vs5Error_pSgtctF"
  },
  "title" : "send(ins:p1:p2:data:le:reply:)"
}
-->

# send(ins:p1:p2:data:le:reply:)

Asynchronously transmits an APDU command to the card, returning the response in a completion handler.

```
func send(ins: UInt8, p1: UInt8, p2: UInt8, data: Data? = nil, le: Int? = nil, reply: @escaping (Data?, UInt16, (any Error)?) -> Void)
```

## Parameters

`ins`

The instruction code.

`p1`

The first parameter.

`p2`

The second parameter.

`data`

The data field, or `nil` if no input data field is present—for example, a `case1` or `case2` APDU.

    The length of the data serves as     `Lc`     field of the APDU.

`le`

The expected number of bytes to be returned, or `nil` if no output data are expected—for example, a `case1` or `case3` APDU. Pass `0` to accept as many bytes as the card provides.

`reply`

A closure to call when the response is returned from the card.

- replyData: The returned data without the first two bytes (`SW1SW2`), or `nil` if an error occurred.
- sw: The result code as represented by the first two bytes (`SW1SW2`) of the returned data.
- error: If a communication error occurred or the result code is anything other than `0x9000`, contains details about the error.

## Discussion

This call handles all ISO7816-4 APDU cases, translating to proper the sequences according to the protocol.  It consults the [`useExtendedLength`](/documentation/CryptoTokenKit/TKSmartCard/useExtendedLength) and [`useCommandChaining`](/documentation/CryptoTokenKit/TKSmartCard/useCommandChaining) properties and uses these modes whenever appropriate for sending the APDU request.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)