Contents

CredentialSession

A class for performing actions on a credential stored in the Secure Element.

Declaration

actor CredentialSession

Mentioned in

Overview

Create a credential session with the startSession() method. After you start a session, the session has three states:

Management

In this default state, you can list, add, and delete credentials in the Secure Element.

Wired

The wired state allows you to exchange data with a credential-corresponding entity (an applet) in the Secure Element.

Card Emulation

In the card emulation state, your credential can communicate with a contactless card reader.

The framework provides SwiftUI and UIKit user interfaces for your app to display while using the wired and card emulation states.

You can read the current state at any time from the state property. The eventStream property provides an AsyncStream of events from both your own actions on credentials and outside sources like detecting an NFC reader’s RF field.

An app can have only one active session at a time. When your app no longer needs the credential session, call invalidate(). If your app goes into the background, the system automatically invalidates your session after a short delay. In wired mode, the system invalidates the session if it goes 15 seconds without performing a transceive(_:) call.

Use a session in an app extension

Certain methods in CredentialSession are only appropriate for use in apps. If you’re writing an app extension, such as for an identity service provider, use only the following methods:

Topics

Verifying eligibility

Accessing hardware information

Managing the credential session life cycle

Accessing the session state

Accessing credentials

Acquiring exclusive foreground privileges

Handling session events

Managing a credential

Performing wired mode actions

Performing card emulation

Using SwiftUI

Handling errors

Infrequently-used functionality

Structures

Enumerations