استرداد المعلومات المتعلقة باستجابة الإعلان

اختيار النظام الأساسي: Android iOS Unity Flutter Android (الإصدار القديم)

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

في الحالات التي يتم فيها تحميل إعلان بنجاح، يحتوي عنصر الإعلان على الموقع GADResponseInfo. على سبيل المثال، GADInterstitialAd.responseInfo يحصل على معلومات الردّ لإعلان بيني تم تحميله.

في الحالات التي يتعذّر فيها تحميل الإعلانات ولا يتوفّر سوى خطأ، يتوفّر GADResponseInfo باستخدام المفتاح GADErrorUserInfoKeyResponseInfo في قاموس userInfo للخطأ.

Swift

fileprivate func loadInterstitial() {
  AdManagerInterstitialAd.load(
    with: "/21775744923/example/interstitial", request: request
  ) { (ad, error) in
    if let error = error {
      let responseInfo = (error as NSError).userInfo[GADErrorUserInfoKeyResponseInfo] as? ResponseInfo
      print("\(String(describing: responseInfo))")
      return
    }
    let responseInfo = ad?.responseInfo
    print("\(String(describing: responseInfo))")
  }
}

Objective-C

- (void)loadInterstitial {
  [GADInterstitialAd
   loadWithAdUnitID:@"/21775744923/example/interstitial"
   request:request
   completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    if (error) {
      GADResponseInfo *responseInfo = error.userInfo[GADErrorUserInfoKeyResponseInfo];
      NSLog(@"%@", responseInfo.description);
      return;
    }
    GADResponseInfo *responseInfo = ad.responseInfo;
    NSLog(@"%@", responseInfo.description);
  }];
}

معلومات الردّ

في ما يلي نموذج للناتج يعرض بيانات تصحيح الأخطاء التي تم عرضها لإعلان تم تحميله:

** Response Info **
    Response ID: BmnCZaSbE_6Mur8P5su8gAY
    Network: GADMAdapterGoogleAdMobAds

  ** Loaded Adapter Response **
    Network: GADMAdapterGoogleAdMobAds
    Ad Source Name:AdMob Network
    Ad Source ID:
    Ad Source Instance Name:AdMob (default)
    Ad Source Instance ID:AdMob (default)
    AdUnitMapping:
{
    pubid = "ca-pub-9939518381636264//21775744923/example/rewarded-interstitial/cak=no_cache&cadc=b0&caqid=BmnCZZjMEvzpkPIP5cWfQA";
}
    Error: (null)
    Latency: 2.724

  ** Extras Dictionary **
    {
        "creative_id" = "138471856178";
        "line_item_id" = "6707237225";
    }

  ** Mediation line items **
    Entry (1)
    Network: GADMAdapterGoogleAdMobAds
    Ad Source Name:AdMob Network
    Ad Source ID:
    Ad Source Instance Name:AdMob (default)
    Ad Source Instance ID:AdMob (default)
    AdUnitMapping:
{
    pubid = "ca-pub-9939518381636264//21775744923/example/rewarded-interstitial/cak=no_cache&cadc=b0&caqid=BmnCZZjMEvzpkPIP5cWfQA";
}
    Error: (null)
    Latency: 2.724

تشمل المواقع في GADResponseInfo ما يلي:

الموقع الوصف
adNetworkInfoArray تعرض قائمة GADAdNetworkResponseInfo التي تحتوي على بيانات وصفية لكل مُنسّق مضمّن في استجابة الإعلان. يمكن استخدامها لتصحيح أخطاء التوسّط المستند إلى العرض الإعلاني بدون انقطاع وعرض الأسعار. يتطابق ترتيب القائمة مع ترتيب تدفق التوسّط لهذا الطلب الإعلاني.

راجِع معلومات استجابة المُنسّق لمزيد من المعلومات.

loadedAdNetworkResponseInfo تعرض GADAdNetworkResponseInfo المقابلة للمُنسّق الذي حمّل الإعلان.
adNetworkClassName تعرض اسم فئة مُنسّق التوسّط لشبكة الإعلانات التي حمّلت الإعلان.
responseIdentifier معرّف الردّ هو معرّف فريد لاستجابة الإعلان. يمكن استخدام هذا المعرّف لتحديد الإعلان وحظره في مركز مراجعة الإعلانات.
extrasDictionary تعرض معلومات إضافية عن استجابة الإعلان. قد تعرض الإضافات المفاتيح التالية:
  • creative_id: رقم تعريف تصميم الإعلان المحدّد. يتم عرضه لإعلانات الحجز فقط.
  • line_item_id: رقم تعريف عنصر () واحد للإعلان المحدّد. يتم عرضه لإعلانات الحجز فقط.

Swift

fileprivate func loadInterstitial() {
  AdManagerInterstitialAd.load(
    with: "/21775744923/example/interstitial", request: request
  ) { (ad, error) in
    let responseInfo = ad?.responseInfo

    let responseIdentifier = responseInfo?.responseIdentifier
    let adNetworkClassName = responseInfo?.adNetworkClassName
    let adNetworkInfoArray = responseInfo?.adNetworkInfoArray
    let loadedAdNetworkResponseInfo = responseInfo?.loadedAdNetworkResponseInfo
    let creativeID = responseInfo?.extrasDictionary["creative_id"]
    let lineItemID = responseInfo?.extrasDictionary["line_item_id"]
  }
}

Objective-C

- (void)loadInterstitial {
  [GADInterstitialAd
   loadWithAdUnitID:@"/21775744923/example/interstitial"
   request:request
   completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    GADResponseInfo *responseInfo = ad.responseInfo;

    NSString *responseIdentifier = responseInfo.responseIdentifier;
    NSString *adNetworkClassName = responseInfo.adNetworkClassName;
    NSArray *adNetworkInfoArray = responseInfo.adNetworkInfoArray;
    GADAdNetworkResponseInfo *loadedAdNetworkResponseInfo = responseInfo.loadedAdNetworkResponseInfo;
    NSString *creativeID = responseInfo.extrasDictionary[@"creative_id"];
    NSString *lineItemID = responseInfo.extrasDictionary[@"line_item_id"];
  }];
}

معلومات استجابة المُنسّق

GADAdNetworkResponseInfo تحتوي على بيانات وصفية لكل مُنسّق مضمّن في استجابة الإعلان، ويمكن استخدامها لتصحيح أخطاء التوسّط المستند إلى العرض الإعلاني بدون انقطاع وعرض الأسعار. يتطابق ترتيب القائمة مع ترتيب تدفق التوسّط لطلب الإعلان.

في ما يلي نموذج لناتج GADAdNetworkResponseInfo:

    Network: GADMAdapterGoogleAdMobAds
    Ad Source Name:AdMob Network
    Ad Source ID:
    Ad Source Instance Name:AdMob (default)
    Ad Source Instance ID:AdMob (default)
    AdUnitMapping:
{
    pubid = "ca-pub-9939518381636264//21775744923/example/rewarded-interstitial/cak=no_cache&cadc=b0&caqid=BmnCZZjMEvzpkPIP5cWfQA";
}
    Error: (null)
    Latency: 2.724

لكل شبكة إعلانات، توفّر GADAdNetworkResponseInfo المواقع التالية:

الموقع الوصف
error الخطأ المرتبط بالطلب المقدَّم إلى الشبكة. تعرض nil إذا حمّلت الشبكة إعلانًا بنجاح أو إذا لم تتم محاولة استخدام الشبكة.
adSourceId رقم تعريف مصدر الإعلان المرتبط باستجابة المُنسّق هذه.
adSourceInstanceId رقم تعريف مثال مصدر الإعلان المرتبط باستجابة المُنسّق هذه.
adSourceInstanceName اسم مثال مصدر الإعلان المرتبط باستجابة المُنسّق هذه. تعرض سلسلة فارغة إذا لم تملأها مجموعة تحقيق الإيرادات.
adSourceName مصدر الإعلان الذي يمثّل شبكة الإعلانات المحدّدة التي تعرض ظهور الإعلان.
adNetworkClassName اسم فئة مُنسّق شبكة الإعلانات الذي حمّل الإعلان.
adUnitMapping إعدادات الشبكة التي تم ضبطها من واجهة مستخدم "مدير إعلانات Google".
latency مقدار الوقت الذي استغرقته شبكة الإعلانات لتحميل إعلان. تعرض 0 إذا لم تتم محاولة استخدام الشبكة.

Swift

fileprivate func loadInterstitial() {
  AdManagerInterstitialAd.load(
    with: "/21775744923/example/interstitial", request: request
  ) { (ad, error) in
    let responseInfo = ad?.responseInfo
    let loadedAdNetworkResponseInfo = responseInfo?.loadedAdNetworkResponseInfo

    let adNetworkError = loadedAdNetworkResponseInfo?.error
    let adSourceId = loadedAdNetworkResponseInfo?.adSourceID
    let adSourceInstanceId = loadedAdNetworkResponseInfo?.adSourceInstanceID
    let adSourceInstanceName = loadedAdNetworkResponseInfo?.adSourceInstanceName
    let adSourceName = loadedAdNetworkResponseInfo?.adSourceName
    let adNetworkClassName = loadedAdNetworkResponseInfo?.adNetworkClassName
    let adUnitMapping = loadedAdNetworkResponseInfo?.adUnitMapping
    let latency = loadedAdNetworkResponseInfo?.latency
  }
}

Objective-C

- (void)loadInterstitial {
  [GADInterstitialAd
   loadWithAdUnitID:@"/21775744923/example/interstitial"
   request:request
   completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    GADResponseInfo *responseInfo = ad.responseInfo;
    GADAdNetworkResponseInfo *loadedAdNetworkResponseInfo = responseInfo.loadedAdNetworkResponseInfo;

    NSError *adNetworkError = loadedAdNetworkResponseInfo.error;
    NSString *adSourceId = loadedAdNetworkResponseInfo.adSourceID;
    NSString *adSourceInstanceId = loadedAdNetworkResponseInfo.adSourceInstanceID;
    NSString *adSourceInstanceName = loadedAdNetworkResponseInfo.adSourceInstanceName;
    NSString *adSourceName = loadedAdNetworkResponseInfo.adSourceName;
    NSString *adNetworkClassName = loadedAdNetworkResponseInfo.adNetworkClassName;
    NSDictionary *adUnitMapping = loadedAdNetworkResponseInfo.adUnitMapping;
    NSTimeInterval latency = loadedAdNetworkResponseInfo.latency;
  }];
}