Łączenie przekazywania dostępu niestandardowych odbiorców z chronioną grupą odbiorców

Interfejs fetchAndJoinCustomAudience API umożliwia kupującym delegowanie dołączenia do niestandardowej listy odbiorców przez wykorzystanie obecności na urządzeniu swoich partnerów MMP lub SSP.

Opis

Ogólnie rzecz biorąc, element wywołujący na urządzeniu (MMP lub SSP SDK) tworzy fetchAndJoinCustomAudienceRequest, który wygląda tak:

Kotlin

/**
 * @param fetchUri The URL to retrieve the CA from.
 * (optional)@param name The name of the CA to join.
 * (optional)@param activationTime The time when the CA will activate.
 * (optional)@param expirationTime The time when the CA will expire,
    must be a time in the future otherwise this will fail
 * (optional)@param userBiddingSignals The user bidding signals used at auction.
*/

val request = FetchAndJoinCustomAudienceRequest.Builder(fetchUri)
    .setName(name)
    .setActivationTime(activationTime)
    .setExpirationTime(expirationTime)
    .setUserBiddingSignals(userBiddingSignals)
    .build()

Java

/**
 * @param fetchUri The URL to retrieve the CA from.
 * (optional)@param name The name of the CA to join.
 * (optional)@param activationTime The time when the CA will activate.
 * (optional)@param expirationTime The time when the CA will expire,
    must be a time in the future otherwise this will fail
 * (optional)@param userBiddingSignals The user bidding signals used at auction.
*/

FetchAndJoinCustomAudienceRequest request =
 new FetchAndJoinCustomAudienceRequest.Builder(fetchUri)
  .setName(name) //Optional
  .setActivationTime(activationTime) //Optional
  .setExpirationTime(expirationTime) //Optional
  .setUserBiddingSignals(userBiddingSignals) //Optional
  .build();

Ważna uwaga dotycząca wszystkich parametrów opcjonalnych polega na tym, że jeśli są one ustawione w żądaniu pobierania, ich danych nie można zastąpić informacjami zwróconymi od kupującego, co daje wywołującemu na urządzeniu dodatkową kontrolę nad tym, które niestandardowe listy odbiorców są przechowywane.

Element fetchUri powinien wskazywać punkt końcowy serwera obsługiwany przez kupującego, który zwraca obiekt JSON dotyczący niestandardowej listy odbiorców zgodny z formatem podanym tutaj:

//Return a 200 response with data matching the format of the following in the body
{
  "daily_update_uri": "https://js.example.com/bidding/daily",
  "bidding_logic_uri": "https://js.example.com/bidding",
  "user_bidding_signals": {
    "valid": true,
    "arbitrary": "yes"
  },
  "trusted_bidding_data": {
    "trusted_bidding_uri": "https://js.example.com/bidding/trusted",
    "trusted_bidding_keys": [
      "key1",
      "key2"
    ]
  },
  "ads": [
    {
      "render_uri": "https://js.example.com/render/fetch_and_join_ad1",
      "metadata": {
        "valid": 1
      }
    },
    {
      "render_uri": "https://js.example.com/render/fetch_and_join_ad2",
      "metadata": {
        "valid": 2
      }
    }
  ]
}

Więcej informacji o tym, jak rozwiązać ten problem po stronie interfejsu API, znajdziesz w propozycji projektu design for Join CA Delegation.

Testowanie

Po zaimplementowaniu wywołania pobierania w kodzie klienta i skonfigurowaniu punktu końcowego po stronie DSP tak, aby zwracały dane o niestandardowych odbiorcach, możesz przetestować przekazywanie dostępu do niestandardowych list odbiorców. Przed uruchomieniem aplikacji musisz uruchomić to polecenie, aby otworzyć interfejs i włączyć Piaskownicę prywatności:

adb shell am start -n com.google.android.adservices.api/com.android.adservices.ui.settings.activities.AdServicesSettingsMainActivity

Gdy pojawi się interfejs, włącz Piaskownicę prywatności i uruchom te polecenia ADB, aby dokończyć konfigurowanie urządzenia na potrzeby testów:

adb shell device_config set_sync_disabled_for_tests persistent
adb shell device_config put adservices ppapi_app_signature_allow_list \"\*\"
adb shell device_config put adservices ppapi_app_allow_list \"\*\"
adb shell device_config put adservices adservice_system_service_enabled true
adb shell device_config put adservices adservice_enabled true
adb shell device_config put adservices adservice_enable_status true
adb shell device_config put adservices global_kill_switch false
adb shell device_config put adservices fledge_js_isolate_enforce_max_heap_size false
adb shell device_config put adservices fledge_custom_audience_service_kill_switch false
adb shell device_config put adservices fledge_select_ads_kill_switch false
adb shell device_config put adservices adid_kill_switch false
adb shell setprop debug.adservices.disable_fledge_enrollment_check true
adb shell device_config put adservices fledge_fetch_custom_audience_enabled true

Po uruchomieniu tych poleceń powinno już być możliwe wykonywanie wywołań za pomocą interfejsu Fetch API.

Aby zobaczyć przykład tego procesu, dodano wywołania pobierania do gałęzi podglądu dla programistów w repozytorium przykładów z Piaskownicy prywatności w GitHubie.