> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/secure-card-display/integrate-d1-sdk/get-started/configuration/3.-initialization/ios-initialization.md).

# iOS initialization

### Overview

`D1Task` is the main entry point to D1 SDK. It should be called as soon as the application is launched or at the earliest possible time. `D1Task.Components` is used to set a one-time configuration. The values can be retrieved from Thales delivery team.

### Configure the D1 SDK

{% stepper %}
{% step %}

### Create a `D1Task` instance

In `SceneDelegate` [scene(:willConnectTo:options:)](https://developer.apple.com/documentation/uikit/uiscenedelegate/3197914-scene), create a `D1Task` instance. Alternatively, in applications that do not use `SceneDelegate`, `D1Task` instance can be created in `AppDelegate` [application(:didFinishLaunchingWithOptions:)](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622921-application)
{% endstep %}

{% step %}

### Configure the SDK

After setting up `D1Task`, issuer application can call the `configure` API to initialize the SDK. There are certain parameters that are required to be provided by the issuer application, for example `consumerID`.
{% endstep %}

{% step %}

### Use multi-issuer tokens

The issuer application can create multiple `D1Tasks` using multi-issuer tokens under the following conditions:

* Each issuer token may include multiple `consumerID` as the `SUB` (subject) for the same issuer.
* A single login can be performed by providing all the issuer tokens which may include multiple `consumerID` separated by spaces. Subsequently, additional operations can then be carried out across different `D1Tasks`.
  {% endstep %}
  {% endstepper %}

### Example

{% code title="SceneDelegate.swift" lineNumbers="true" %}

```swift
var d1Task: D1Task!

let PUBLIC_KEY_EXPONENT: [UInt8] = [0x00, 0xa0] // Modulus bytes array
let PUBLIC_KEY_MODULUS: [UInt8] = [0x00, 0x00] // Exponent bytes array

var comp = D1Task.Components()
comp.d1ServiceURLString = ""
comp.issuerID = ""
comp.d1ServiceRSAExponent = Data(bytes: PUBLIC_KEY_EXPONENT, count: PUBLIC_KEY_EXPONENT.count)
comp.d1ServiceRSAModulus = Data(bytes: PUBLIC_KEY_MODULUS, count: PUBLIC_KEY_MODULUS.count)
comp.digitalCardURLString = ""
d1Task = comp.task()

// Initialize required SDKs
// Issuer application is required to provide consumerID
let consumerID = "" // obtained e.g. from server
let coreConfig = ConfigParams.coreConfig(consumerID: consumerID)
// required for Card Processing & Wallet Pay
let cardConfig = ConfigParams.cardConfig()

d1Task.configure([coreConfig, cardConfig]) { (errors) in
    if let errors = errors {
        for error in errors {
            // Check error details to see whose config cause the errors, refer to D1 SDK Integration – Error Management section
        }
    }
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.payments.thalescloud.io/secure-card-display/integrate-d1-sdk/get-started/configuration/3.-initialization/ios-initialization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
