I have implemented an AdMob banner view ad, and also the GADBannerViewDelegate
protocol as defined here:
https://developers.google.com/admob/ios/banner
So I can use this callback:
/// Tells the delegate an ad request failed.
func adView(_ bannerView: GADBannerView,
didFailToReceiveAdWithError error: GADRequestError) {
print("adView:didFailToReceiveAdWithError: \(error.localizedDescription)")
}
I can see from the file that defines GADRequestError
that there is also a GADErrorCode
enum:
https://github.com/floatinghotpot/google-admob-sdk/blob/master/src/ios/GADRequestError.h
Which is documented here: https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Enums/GADErrorCode
-
However I am really struggling trying to get the GADErrorCode
enum object from the GADRequestError
error object.
-
This is the value of the GADRequestError
error object when the ad fails to load because the device is offline:
Error Domain=com.google.admob Code=-1009 "The Internet connection appears to be offline." UserInfo={NSUnderlyingError=0x600000f46880 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "The Internet connection appears to be offline." UserInfo={NSErrorFailingURLStringKey=https://googleads.g.doubleclick.net/mads/static/sdk/native/sdk-core-v40.html?sdk=afma-sdk-i-v7.36.0, NSErrorFailingURLKey=https://googleads.g.doubleclick.net/mads/static/sdk/native/sdk-core-v40.html?sdk=afma-sdk-i-v7.36.0, _kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1, NSLocalizedDescription=The Internet connection appears to be offline.}}, NSErrorFailingURLStringKey=https://googleads.g.doubleclick.net/mads/static/sdk/native/sdk-core-v40.html?sdk=afma-sdk-i-v7.36.0, NSErrorFailingURLKey=https://googleads.g.doubleclick.net/mads/static/sdk/native/sdk-core-v40.html?sdk=afma-sdk-i-v7.36.0, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, NSLocalizedDescription=The Internet connection appears to be offline.}
Can that be converted somehow into a GADErrorCode
enum object?