在指令列檢查自訂目標對象

Protected Audience 提供一系列 API,用於彙整及退出自訂目標對象,做為 android.adservices.customaudience 套件的一部分。為了進行偵錯,您可以使用 CLI 指令列出及查看自訂目標對象。本指南將概述廣告技術開發人員需要採取哪些步驟,才能檢查已加入自訂目標對象的狀態。

設定

基於安全性和隱私權考量,自訂目標對象預設不會顯示,且只能直接檢查偵錯用途。只有在符合下列需求的情況下,才能使用這些指令查看:

  • 已啟用整個系統的開發人員選項
  • android:debuggable="true" 會在加入 CustomAudience 的應用程式 AndroidManifest.xml 檔案中宣告 (使用 joinCustomAudiencefetchAndJoinCustomAudience)
  • 「應用程式建議廣告的同意聲明」設定已開啟

啟用 adservices shell 指令

  1. 請重新啟動裝置,終止「adservices」程序。
  2. 確認 adservices 並未執行。下列指令應有空白輸出。
adb shell ps -A | grep adservices

接著,如要啟用 adservices 殼層指令,請執行下列指令:

adb shell setprop debug.adservices.adservices_shell_command_enabled true
adb shell setprop debug.adservices.fledge_is_custom_audience_cli_enabled true

名單自訂目標對象

如要查看特定自訂目標對象,請執行下列指令,將 owner 指定為建立目標對象的套件,並將 buyer 指定為管理目標對象的廣告聯播網 ID:

adb shell cmd adservices_manager custom-audience list --owner <owner> --buyer <buyer>

輸出結果會是內含陣列 custom_audiences 的 JSON 物件。此陣列中的元素結構,與下方所述的資料檢視自訂目標對象指令輸出內容相符。

查看特定自訂目標對象

如要查看特定自訂目標對象,請執行下列指令,將 owner 指定為建立目標對象的套件、buyer 做為管理目標對象的廣告聯播網 ID,以及 name 做為目標對象名稱:

adb shell cmd adservices_manager custom-audience view --owner <owner> --buyer <buyer> --name <name>

重新整理特定自訂目標對象

如要針對特定自訂目標對象手動觸發每日更新,請執行下列指令,將 owner 指定為建立目標對象的套件、buyer 做為管理目標對象的廣告聯播網 ID,以及 name 做為目標對象名稱:

adb shell cmd adservices_manager custom-audience refresh --owner <owner> --buyer <buyer> --name <name>
> Successfully updated custom audience.