বিজ্ঞাপন লোড ত্রুটি

যখন একটি বিজ্ঞাপন লোড হতে ব্যর্থ হয়, সেখানে সর্বদা একটি প্রতিনিধি পদ্ধতি বা সমাপ্তি হ্যান্ডলার বলা হয় যা একটিNSError অবজেক্ট প্রদান করে।

a GADBannerViewএর জন্য, নিম্নলিখিতটিকে বলা হয়:

সুইফট

func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error)

উদ্দেশ্য গ

- (void)bannerView:(nonnull GADBannerView *)bannerView
    didFailToReceiveAdWithError:(nonnull NSError *)error;

এখানে একটি কোড স্নিপেট রয়েছে যা একটি বিজ্ঞাপন লোড হতে ব্যর্থ হলে উপলব্ধ তথ্য তুলে ধরে:

সুইফট

func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) {
    // Gets the domain from which the error came.
    let errorDomain = error.domain
    // Gets the error code. See
    // https://developers.google.com/admob/ios/api/reference/Enums/GADErrorCode
    // for a list of possible codes.
    let errorCode = error.code
    // Gets an error message.
    // For example "Account not approved yet". See
    // https://support.google.com/admob/answer/9905175 for explanations of
    // common errors.
    let errorMessage = error.localizedDescription
    // Gets additional response information about the request. See
    // https://developers.google.com/admob/ios/response-info for more information.
    let responseInfo = (error as NSError).userInfo[GADErrorUserInfoKeyResponseInfo] as? GADResponseInfo
    // Gets the underlyingError, if available.
    let underlyingError = (error as NSError).userInfo[NSUnderlyingErrorKey] as? Error
    if let responseInfo = responseInfo {
        print("Received error with domain: \(errorDomain), code: \(errorCode),"
          + "message: \(errorMessage), responseInfo: \(responseInfo),"
          + "underlyingError: \(underlyingError?.localizedDescription ?? "nil")")
    }
}

উদ্দেশ্য গ

- (void)bannerView:(GADBannerView *)bannerView
    didFailToReceiveAdWithError:(NSError *)error {
  // Gets the domain from which the error came.
  NSString *errorDomain = error.domain;
  // Gets the error code. See
  // https://developers.google.com/admob/ios/api/reference/Enums/GADErrorCode
  // for a list of possible codes.
  int errorCode = error.code;
  // Gets an error message.
  // For example "Account not approved yet". See
  // https://support.google.com/admob/answer/9905175 for explanations of
  // common errors.
  NSString *errorMessage = error.localizedDescription;
  // Gets additional response information about the request. See
  // https://developers.google.com/admob/ios/response-info for more
  // information.
  GADResponseInfo *responseInfo = error.userInfo[GADErrorUserInfoKeyResponseInfo];
  // Gets the underlyingError, if available.
  NSError *underlyingError = error.userInfo[NSUnderlyingErrorKey];
  NSLog(@"Received error with domain: %@, code: %ld, message: %@, "
        @"responseInfo: %@, underlyingError: %@",
        errorDomain, errorCode, errorMessage, responseInfo,
        underlyingError.localizedDescription);
}

বিজ্ঞাপন লোড ব্যর্থ হওয়ার কারণ কী তা নির্ধারণ করতে এই তথ্যটি আরও সঠিকভাবে ব্যবহার করা যেতে পারে।বিশেষ করে, GADErrorDomain , localizedDescription বিবরণ এই সহায়তা কেন্দ্রের নিবন্ধে দেখা যেতে পারে এবং আরও বিস্তারিত ক্রিয়াকলাপ ব্যাখ্যা করতে পারে। সমস্যা সমাধানের জন্য নেওয়া হয়েছে।