<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoTokenKit",
  "identifier" : "/documentation/CryptoTokenKit/TKSmartCardTokenDriverDelegate/tokenDriver(_:createTokenFor:aid:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "CryptoTokenKit"
    ],
    "preciseIdentifier" : "c:objc(pl)TKSmartCardTokenDriverDelegate(im)tokenDriver:createTokenForSmartCard:AID:error:"
  },
  "title" : "tokenDriver(_:createTokenFor:aid:)"
}
-->

# tokenDriver(_:createTokenFor:aid:)

Tells the delegate that a new Smart Card is detected.

```
func tokenDriver(_ driver: TKSmartCardTokenDriver, createTokenFor smartCard: TKSmartCard, aid AID: Data?) throws -> TKSmartCardToken
```

## Parameters

`driver`

The Smart Card token driver.

`smartCard`

The detected Smart Card.

`AID`

The ISO 7816-4 application identifier that is selected on the Smart Card. If the `com.apple.ctk.aid` attributes is not present in the Smart Card token extension property list, no application is selected.

## Return Value

The token created for the Smart Card, or `nil` if an error occurs or the delegate decides not to provide a token.

---

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)