广告投放受限和第一方标识符设置

如果您更新了 Ad Manager 设置“程序化受限广告”或“应用内广告的第一方标识符”,请使用这些新 API 来匹配 Ad Manager 中的设置。如果您不使用这些 API,PAL 可能会在向服务器发送的广告请求中使用的 Nonce 中包含标识符。不过,Ad Manager 可能会根据 Ad Manager 中的设置舍弃这些信号。

这些 API 如下所示:

  • disableLimitedAdsStorage - 停用仅用于检测无效流量的标识符,并禁止为受限广告使用本地存储。如果您在 Ad Manager 的管理 > 全局设置中更新了程序化受限广告设置,请使用此 API 在 PAL 中停用对受限广告使用本地存储空间。请注意,此设置不适用于无限制广告。
  • disableFirstPartyIdentifiers - 停用用于广告选择的第一方标识符。如果您在 Ad Manager 的管理 > 全局设置中更新了应用内广告的第一方标识符设置,请使用此 API 在 PAL 中停用此类标识符。请注意,此设置不适用于将标识符和本地存储空间用于检测无效流量的情况。

以下示例设置了这些参数:

ConsentSettings consentSettings = ConsentSettings.builder()
            .allowStorage(isConsentToStorage)
            .build();

GoogleAdManagerSettings adManagerSettings = GoogleAdManagerSettings.builder()
            // Add this line if the "Programmatic limited ads" toggle is turned
            // off in Ad Manager.
            .disableLimitedAdsStorage(true)
            // Add this line if the
            // "First party identifiers for ads on app" toggle is turned
            // off in Ad Manager.
            .disableFirstPartyIdentifiers(true)
            .build();

nonceLoader = new NonceLoader(this, consentSettings, adManagerSettings);