광고 로드에 실패하면 GADRequestError
객체를 제공하는
대리자 메서드 또는 완료 핸들러가
항상 호출됩니다.
a GADBannerView
의 경우 다음이 호출됩니다.
Swift
func adView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: GADRequestError)
Objective-C
- (void)adView:(nonnull GADBannerView *)bannerView didFailToReceiveAdWithError:(nonnull GADRequestError *)error;
다음은 광고 로드에 실패할 때 제공될 수 있는 정보를 보여주는 코드 스니펫입니다.
Swift
func adView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: GADRequestError) { // 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.userInfo[GADErrorUserInfoKeyResponseInfo] as? GADResponseInfo // Gets the underlyingError, if available. let underlyingError = error.userInfo[NSUnderlyingErrorKey] as? Error if let responseInfo = responseInfo { print("Received error with domain: \(errorDomain), code: \(errorCode)," + "message: \(errorMessage), responseInfo: \(responseInfo)," + "underLyingError: \(underlyingError?.localizedDescription ?? "nil")") } }
Objective-C
- (void)adView:(GADBannerView *)adView didFailToReceiveAdWithError:(GADRequestError *)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); }
이 정보를 사용하여 광고 로드에 실패한 원인을 보다 정확하게
파악할 수 있습니다.
특히
kGADErrorDomain
도메인에 속한 오류의 경우 localizedDescription
을
이 고객센터
도움말에서 조회하여 자세한 내용을 확인하고
문제를 해결하기 위해 취할 수 있는 조치에 대해 알아볼 수
있습니다.