我已经实现了 AdMob 横幅视图广告,以及GADBannerViewDelegate
此处定义的协议:
https ://developers.google.com/admob/ios/banner
所以我可以使用这个回调:
/// Tells the delegate an ad request failed.
func adView(_ bannerView: GADBannerView,
didFailToReceiveAdWithError error: GADRequestError) {
print("adView:didFailToReceiveAdWithError: \(error.localizedDescription)")
}
我可以从定义的文件中看到GADRequestError
还有一个GADErrorCode
枚举:
https ://github.com/floatinghotpot/google-admob-sdk/blob/master/src/ios/GADRequestError.h
此处记录: https ://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Enums/GADErrorCode
-
但是,我真的很难从错误对象中获取GADErrorCode
枚举对象。GADRequestError
-
这是GADRequestError
由于设备离线而无法加载广告时的错误对象的值:
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.}
可以以某种方式将其转换为GADErrorCode
枚举对象吗?