ออบเจ็กต์ AdResult
รายการมีกลไกในการตรวจจับความพยายามโหลดโฆษณาไม่สำเร็จ
หากเกิดข้อผิดพลาด เมธอด AdResult
is_successful()
จะคืนค่า "เท็จ"
ในสถานการณ์เหล่านี้ การเรียกใช้เมธอด 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 คุณสามารถค้นหาข้อความได้จากบทความในศูนย์ช่วยเหลือนี้เพื่อดูคำอธิบายโดยละเอียดเพิ่มเติมและการดำเนินการที่เป็นไปได้ที่สามารถทำตามเพื่อแก้ไขปัญหาได้