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 の場合)とドメイン com.google.android.gms.ads
(Android の場合)のエラーについては、こちらのヘルプセンターの記事で、メッセージの詳細な説明と、問題を解決するために実行できるアクションを確認してください。