---
updatedAt: 2026-11-11T10:49:16.000Z
agentTools:
  siteIndex: https://developer.paymentology.com/llms.txt
  projectIndex: https://developer.paymentology.com/lume/llms.txt
---

# iOS Initialize

# iOS SDK: Initialize

Initialize the iOS Digital Card Engine UI SDK along with the underlying Ei Card Provider core SDK. Call `DigitalCardEngine(token:)` early in your app’s lifecycle—typically after your backend provides an auth token.

Prerequisites:

* Repositories and dependencies configured (see the iOS **Setup** guide).
* A runtime token issued by your backend.

## What DigitalCardEngine(token:) does

* Configures the core SDK with your bearer token and selected environment.
* Bootstraps MeaWallet’s MCD library for secure card image rendering.
* Loads fonts and assets required by the microfrontends.

## Basic initialization

```swift
import DigitalCardEngineSDK
import Combine

class CardService: CardServiceProtocol {
    
    let sessionManager: SessionManagerProtocol
    var sdk: DigitalCardEngine?
    private var cancellables = Set<AnyCancellable>()
    
    init(sessionManager: SessionManagerProtocol) {
        self.sessionManager = sessionManager
        
        sessionManager.token.sink { token in
            if let tokenString = token {
                self.sdk = DigitalCardEngine(token: tokenString)
            } else {
                self.sdk = nil
            }
        }
        .store(in: &cancellables)
    }
}
```

Guidelines (quick checklist):

* Supply non-empty tokens (the SDK rejects blank/too-short values). Never commit secrets.
* Keep one shared `DigitalCardEngine` instance (application singleton/DI) and reuse it across screens.
* Initialize the engine after you have the token (e.g., post-login).
* After init, you can immediately read or modify `sdk.styleConfiguration` to theme UI components.

## Environments

Use `Environment.DEV`, `Environment.TEST`, or `Environment.PROD`. The default for initialization is `TEST`. The core SDK resolves base URLs from the `card_provider_sdk` build config:

* DEV → `https://ei.dev.meawallet.app`
* TEST → `https://ei.tst.meawallet.app`
* PROD → `https://ei.prd.meawallet.app`

## Token refresh

When your backend issues a new token, update the already-initialized core SDK—no need to recreate `DigitalCardEngineSDK`:

```swift
import DigitalCardEngineSDK

// Called whenever you obtain a fresh token
func refreshToken(newToken: String) {
  sdk.updateAuthToken(newToken)
}
```

## Troubleshooting

* **"Auth token cannot be empty or blank"**: ensure you supply a runtime token string.
* **"Auth token appears to be too short"**: token validation failed; fetch a real token from your backend.
* **MCD errors** during card image rendering usually indicate missing TOTP secrets, missing card selection, or corrupted MCD artifacts/config files.

Next steps: continue to the setup/install page to add repos + dependencies, then use the Card List / Card Details pages to render UI.

# Sibling pages

* [Android Setup](https://developer.paymentology.com/lume/docs/android-setup.md)
* [Android Initialize](https://developer.paymentology.com/lume/docs/android-initialize.md)
* [iOS Setup](https://developer.paymentology.com/lume/docs/ios-setup.md)