الانضمام إلى ميزة "تفويض الجمهور المخصّص" باستخدام ميزة "الجمهور المحمي"

تسمح واجهة برمجة التطبيقات fetchAndJoinCustomAudience للمشترين بتفويض عملية الانضمام إلى جمهور مخصّص من خلال الاستفادة من حضور الشركاء المتعددين للتسويق (MMP) أو منصات الخدمة (SSP) على الجهاز.

نظرة عامة

في ما يلي نظرة عامة حول آلية عمل ذلك: المتصل على الجهاز (سواء كان MMP أو SSP SDK) ينشئ fetchAndJoinCustomAudienceRequest على النحو التالي:

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();

وتجدر الإشارة إلى أنه في حال تعيين جميع المعلمات الاختيارية داخل طلب الجلب، لا يمكن إلغاء بياناتها بما يتم إرجاعه من المشتري، مما يمنح المتصل الذي على الجهاز فقط عناصر تحكم إضافية في نوع الجمهور المخصص الذي يتم الاحتفاظ به.

يجب أن تشير السمة fetchUri إلى نقطة نهاية الخادم التي يديرها "المشتري" والتي ستُرجع كائن JSON المخصّص للجمهور المخصّص الذي يطابق التنسيق الموضّح هنا:

//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
      }
    }
  ]
}

ويمكن الاطّلاع على مزيد من المعلومات حول كيفية حلّ هذه المشكلة من جانب واجهة برمجة التطبيقات في مقترح التصميم للانضمام إلى تفويض مرجع التصديق.

الاختبار

بعد تنفيذ طلب الجلب داخل رمز العميل وإعداد نقطة نهاية على جانب نظام معالجة البيانات (DSP) لعرض بيانات الجمهور المخصّص، يمكنك اختبار تفويض الانضمام إلى جمهور مخصّص. قبل تشغيل تطبيقك، عليك تشغيل الأمر التالي لفتح واجهة المستخدم لتفعيل "مبادرة حماية الخصوصية":

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

بعد ظهور واجهة المستخدم، تأكّد من التبديل لتفعيل "مبادرة حماية الخصوصية"، ثم تشغيل أوامر ADB التالية لإنهاء إعداد الجهاز للاختبار:

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

بعد تشغيل هذه الأوامر، من المفترض أن تتمكن من بدء إجراء الاتصالات بنجاح باستخدام واجهة برمجة تطبيقات الجلب.

للاطّلاع على مثال على هذا المسار، تمّت إضافة طلبات الجلب إلى فرع معاينة المطوّرين لمستودع نماذج "مبادرة حماية الخصوصية" على جيت هب.