> For the complete documentation index, see [llms.txt](https://platform-business.gitbook.io/adx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform-business.gitbook.io/adx/zh/ios/sdk-integration/initialize.md). Agents can also search and read this documentation through its [MCP server](https://platform-business.gitbook.io/adx/~gitbook/mcp).

# Initialize

## SDK Initialize

* 在加载广告之前，请通过调用 `initializeWithConfiguration:completionHandler:` 初始化 ADX SDK。此操作仅需在应用启动时执行一次。
* 创建 `ADXConfiguration` 对象时，请在 `appId` 参数中输入您获取的 ADX APP ID，`gdprType` 参数请使用 `ADXGdprTypeDirectNotRequired` 或 `ADXGdprTypePopupLocation`。

{% tabs %}
{% tab title="Objective-C" %}

```objectivec
// 创建 ADXConfiguration 对象
  // 如果计划在 EEA（欧洲经济区）地区提供服务，请使用 "ADXGdprTypePopupLocation"
  // 如果无计划在 EEA（欧洲经济区）地区提供服务，请使用 "ADXGdprTypeDirectNotRequired"
ADXConfiguration *configuration = 
[[ADXConfiguration alloc] initWithAppId:@"<ADX_APP_ID>"
    gdprType:ADXGdprTypeDirectNotRequired
    testDevices:@[@""]];
    
// 尝试初始化 ADX SDK                                                    
[[ADXSdk sharedInstance] initializeWithConfiguration:configuration
                                   completionHandler:^(BOOL result, ADXConsentState consentState) {
    // 收到初始化完成回调后加载广告
    NSLog(@"ADX Sdk Initialize");
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
// 创建 ADXConfiguration 对象
  // 如果计划在 EEA（欧洲经济区）地区提供服务，请使用 "ADXGdprTypePopupLocation"
  // 如果无计划在 EEA（欧洲经济区）地区提供服务，请使用 "ADXGdprTypeDirectNotRequired"
let configuration = 
    ADXConfiguration(appId: "<ADX_APP_ID>", 
        gdprType: .directNotRequired,
        testDevices: [""])
        
// 尝试初始化 ADX SDK   
ADXSdk.sharedInstance().initialize(with: configuration) { result, consentState in
    // 收到初始化完成回调后加载广告
    print("ADX SDK Initialize")
}
```

{% endtab %}
{% endtabs %}
