iOS SDK(预览)
iOS SDK(预览)
预览状态:当前仓库公开,但没有正式版本标签。接口、安装方式和兼容范围可能调整;不要把未固定的
main分支当作稳定生产依赖。
源码:cnb.cool/mliev/entmesh/sdk-ios
当前 Package 声明支持 iOS 13+,产品名为 Entmesh。
预览接入
克隆公开源码,在 Xcode 的 Package Dependencies 中使用 Add Local Package 指向克隆目录。正式标签发布后,应改用精确版本规则并提交 Package.resolved。
控制台准备
在目标环境登记应用 Bundle ID,例如 com.example.shop.ios,并保存该环境的 ck_… Client Key。
初始化
import Entmesh
Entmesh.initialize(.init(
endpoint: URL(string: "https://collector.entmesh.mliev.com")!,
clientKey: "ck_替换为当前环境的ClientKey",
applicationID: Bundle.main.bundleIdentifier,
consent: .pending
))
Entmesh.consent(.grant)
Entmesh.track("signup_completed", properties: ["plan": "team"])默认同意状态为 .pending。只有切换到 .grant 后才采集和发送;.deny 清空队列,.revoke 还会清除本地身份状态。
页面与身份
SwiftUI:
CheckoutView()
.entmeshScreen("Checkout")UIKit:
let observer = EntmeshNavigationObserver()
observer.didShow("Checkout")登录和退出:
Entmesh.identify("user-42", properties: ["account_type": "team"])
Entmesh.reset()需要立即尝试发送时调用 Entmesh.flush();应用或测试生命周期结束时调用 Entmesh.shutdown()。
IDFV 与 IDFA
Entmesh.initialize(.init(
endpoint: URL(string: "https://collector.entmesh.mliev.com")!,
clientKey: "ck_替换为当前环境的ClientKey",
consent: .pending,
identifierProviders: [IDFVProvider(), IDFAProvider()]
))IDFVProvider提供 Identifier for Vendor。IDFAProvider只有在宿主应用已取得 ATT 授权时返回值。- SDK 不负责展示 ATT 弹窗;宿主应用完成授权流程后调用
Entmesh.refreshDeviceIdentifiers()。
不要为了分析接入绕过 ATT 或用户隐私选择。客户端批次使用 HPKE 加密;公钥获取或加密失败时保留队列,不降级发送明文。