---
title: "tokenDriver(_:createTokenFor:aid:)"
framework: cryptotokenkit
role: symbol
role_heading: Instance Method
path: "cryptotokenkit/tksmartcardtokendriverdelegate/tokendriver(_:createtokenfor:aid:)"
---

# tokenDriver(_:createTokenFor:aid:)

Tells the delegate that a new Smart Card is detected.

## Declaration

```swift
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

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