- 检索应用广告ID,用于竞价、报告曝光量和报告广告归因。(
fetchAdvertisingId) - 检索用户对基于兴趣的广告偏好。(
isAdvertisingTrackingEnabled)
行为
- Verify tracking before you use the advertising ID. Call
isAdvertisingTrackingEnabledand check the result before you use the value fromfetchAdvertisingIdfor interest-based advertising. If it returnsfalse, the user has opted out of interest-based advertising, so serve contextual (non-personalized) advertisements rather than interest-based ones. - Child profiles. On a child profile,
isAdvertisingTrackingEnabledreturnsfalseregardless of the Interest-based Ads setting. The user has opted out of interest-based advertising, so serve contextual (non-personalized) advertisements rather than interest-based ones. - Service unavailable.
fetchAdvertisingIdreturns an empty string if it cannot reach the Advertising Manager service. This does not raise an error. An empty string means the Advertising Manager service was unreachable. Do not use an empty string as a valid advertising ID.
开始使用
设置
- 将以下库依赖项添加到package.json文件的
dependencies部分。
-
在您的manifest.toml中,添加访问Ad ID Retriever所需的以下权限。
用法
此示例演示如何实现Ad ID Retriever服务。该示例提供了一个带有两个按钮的简单用户界面,这些按钮展示了两个核心功能:获取广告ID和检查广告跟踪状态。API参考
类
- AdIdRetriever—AdIdRetriever提供用于检索广告ID和广告跟踪状态的API。

