iOS 接入指南
在 iOS 应用中集成 XXinstall 归因 SDK。
概述
iOS 归因 SDK 核心逻辑以预编译的 XCFramework 二进制分发,支持 React Native (Expo)、Flutter 和纯原生 Swift 三种接入方式。归因完成后自动上报设备画像(去重/防刷)。
接入方式
纯原生 Swift 项目
如果你的 iOS 项目不使用 React Native,可以直接集成 XCFramework:
集成 XCFramework
- 将
XXinstallCore.xcframework拖入 Xcode 项目 - 在 Target → General → Frameworks, Libraries, and Embedded Content 中确认已添加
- 调用 SDK:
import XXinstallCore
// 设置 API 地址
XXinstall.setHost("https://your-api-domain.com")
// 初始化并获取归因结果
let config = XXinstallConfig(
appKey: "YOUR_APP_KEY",
appSecret: "YOUR_APP_SECRET",
debug: true
)
XXinstall.initialize(config: config) { result in
switch result {
case .success(let attr):
print("归因: inviteCode=\(attr.inviteCode ?? "nil"), channel=\(attr.channel)")
case .failure(let error):
print("归因失败: \(error.localizedDescription)")
}
}
可选参数
| 参数 | 类型 | 说明 |
|---|---|---|
skipWebView | Bool | 跳过内置 WebView 指纹采集(默认 false) |
webViewFingerprint | String: Any? | 外部传入 WebView 指纹(用于自定义采集场景) |