1. 导入 InMobi SDK 头文件并进行初始化:
IMSdk.initWithAccountID(<span class="hljs-string">"accountID"</span>, consentDictionary: [IM_GDPR_CONSENT_AVAILABLE:
<span class="hljs-string">"true"</span>, IM_GDPR_CONSENT_IAB: <span class="hljs-string">"<<consent in IAB format>>"</span> ]) { (<span class="hljs-built_in">error</span>) <span class="hljs-keyword">in</span>
<span class="hljs-keyword">if</span> let <span class="hljs-built_in">error</span> = <span class="hljs-built_in">error</span> {
<span class="hljs-built_in">print</span>(<span class="hljs-built_in">error</span>.localizedDescription)
}
}
2. 创建如下用户数据模型:
let phoneNumber = <span class="hljs-title function_ invoke__">IMUserDataTypes</span>(<span class="hljs-attr">md5</span>: <span class="hljs-string">"2wse3e"</span>, <span class="hljs-attr">sha256</span>: <span class="hljs-string">"6tghjk"</span>)
let emailId = <span class="hljs-title function_ invoke__">IMUserDataTypes</span>(<span class="hljs-attr">md5</span>: <span class="hljs-string">"ujhjk99"</span>, <span class="hljs-attr">sha256</span>: <span class="hljs-string">"jhjyure4"</span>)
let userDataModel = <span class="hljs-title function_ invoke__">IMUserDataModel</span>(<span class="hljs-attr">phoneNumber</span>: phoneNumber, <span class="hljs-attr">emailId</span>: emailId, <span class="hljs-attr">extra</span>: nil)
3. 将此数据模型传递给 API 获取数据:
IMUnifiedIdService.<span class="hljs-title function_ invoke__">push</span>(<span class="hljs-attr">data</span>: userDataModel)
4. 调用此 API 获取 UnifID。
IMUnifiedIdService.<span class="hljs-title function_ invoke__">fetchUnifiedIds</span>(<span class="hljs-attr">delegate</span>: <span class="hljs-built_in">self</span>)
实现以下委托以接收回调。
<span class="hljs-keyword">class</span> <span class="hljs-title class_">ViewController</span>: <span class="hljs-title class_">IMUnifiedIdInterface</span> {
<span class="hljs-title function_">onFetchCompleted</span>(<span class="hljs-params">response: Dictionary?, error: <span class="hljs-built_in">Error</span>?</span>) {
}
}
调用此重置 API 以清除 SDK 中存储的所有用户相关数据和 ID:
IMUnifiedIdService<span class="hljs-selector-class">.reset</span>()
如果您拥有供应商提供的 ID,则可以在以下 SDK 中使用它。如果存在重叠,系统将优先使用 InMobi 获取的统一 ID。
IMSdk<span class="hljs-selector-class">.setPublisherProvidedUnifiedID</span>(unifiedIds : Dictionary?);
JSONObject 结构:
<span class="hljs-punctuation">{</span>
<span class="hljs-attr">"id5"</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">"json(blob)"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"liveramp"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"json(blob)"</span>
<span class="hljs-punctuation">}</span>
By installing this SDK update, you agree that your Children Privacy Compliance setting remains accurate or that you will update that setting, whenever there is a change in your app's audience. You may update the app's Children Privacy Compliance settings at https://publisher.inmobi.com/my-inventory/app-and-placements.
Support Center