AdResult
对象提供了一种机制,用于检测尝试加载广告失败的次数。
如果发生故障,AdResult
方法 is_successful()
将返回 false。
在这些情况下,调用 AdResult
方法 ad_error()
将返回
包含错误相关信息的 AdError
对象。
下面的代码段说明了 无法加载:
firebase::Future<firebase::gma::AdResult> load_ad_future =
ad_view->LoadAd(request);
// In a game loop, monitor the load ad status
if (load_ad_future.status() == firebase::kFutureStatusComplete) {
const firebase::gma::AdResult* ad_result = load_ad_future.result();
if (!ad_result.is_successful()) {
// There was an error loading the ad.
const AdError& ad_error = ad_result.ad_error();
firebase::gma::AdErrorCode code = ad_error.code();
std::string domain = ad_error.domain();
std::string message = ad_error.message();
const firebase::gma::ResponseInfo response_info = ad_error.response_info();
printf("Received error with domain: %s, code: %d, message: %s and response info: %s\n”,
domain.c_str(), message.c_str(), response_info.ToString().c_str());
}
}
此信息可用于更准确地确定导致广告出现的原因
加载失败。尤其是当网域为 com.google.admob
下的错误时,
iOS 和 Android 上的 com.google.android.gms.ads
,可以在
请参阅这篇帮助中心文章
详细说明,以及可以采取哪些措施来解决
问题。