---
title: "beginSession(reply:)"
framework: cryptotokenkit
role: symbol
role_heading: Instance Method
path: "cryptotokenkit/tksmartcard/beginsession(reply:)"
---

# beginSession(reply:)

Begins a session with the Smart Card.

## Declaration

```swift
func beginSession(reply: @escaping @Sendable (Bool, (any Error)?) -> Void)
```

```swift
func beginSession() async throws -> Bool
```

## Parameters

- `reply`: The NSError object is created in the doc://com.apple.cryptotokenkit/documentation/CryptoTokenKit/TKErrorDomain domain with a code in the doc://com.apple.cryptotokenkit/documentation/CryptoTokenKit/TKError/Code enumeration.

## Discussion

Discussion This method will fail if there is already an existing session for the Smart Card. Calls to this method must be balanced with calls to endSession().

## See Also

### Communicating with the Smart Card

- [transmit(_:reply:)](cryptotokenkit/tksmartcard/transmit(_:reply:).md)
- [endSession()](cryptotokenkit/tksmartcard/endsession().md)
