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

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

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

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

Swift

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

Objective-C

- (void)loadInterstitial {
  [GADInterstitialAd
   loadWithAdUnitID:@"/6499/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 **
    {
    }

  ** 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 معرّف الاستجابة هو معرّف فريد لاستجابة الإعلان. ويمكن استخدام هذا المعرّف لتحديد الإعلان وحظره في مركز مراجعة الإعلانات (ARC).
extrasDictionary

عرض معلومات إضافية عن استجابة الإعلان.

Swift

fileprivate func loadInterstitial() {
  GADInterstitialAd.load(
    withAdUnitID: "/6499/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
  }
}

Objective-C

- (void)loadInterstitial {
  [GADInterstitialAd
   loadWithAdUnitID:@"/6499/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;
  }];
}

معلومات استجابة المحوّل

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 تم ضبط إعدادات الشبكة من واجهة المستخدم Ad Manager .
latency مقدار الوقت الذي استغرقته شبكة الإعلانات في تحميل أحد الإعلانات. تعرض 0 إذا لم تتم محاولة الاتصال بالشبكة.

Swift

fileprivate func loadInterstitial() {
  GADInterstitialAd.load(
    withAdUnitID: "/6499/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:@"/6499/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;
  }];
}