Lỗi khi tải quảng cáo

Khi quảng cáo không tải được, một lệnh gọi lại không thành công sẽ được gọi để cung cấp đối tượng LoadAdError.

Đoạn mã sau đây truy xuất thông tin lỗi khi quảng cáo không tải được:

public void OnAdFailedToLoad(LoadAdError error)
{
    // Gets the domain from which the error came.
    string domain = error.GetDomain();

    // Gets the error code. See
    // https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdRequest
    // and https://developers.google.com/admob/ios/api/reference/Enums/GADErrorCode
    // for a list of possible codes.
    int code = error.GetCode();

   // Gets an error message.
   // For example "Account not approved yet". See
   // https://support.google.com/admob/answer/9905175 for explanations of
   // common errors.
   string message = error.GetMessage();

   // Gets the cause of the error, if available.
   AdError underlyingError = error.GetCause();

   // All of this information is available through the error's toString() method.
   Debug.Log("Load error string: " + error.ToString());

   // Get response information, which may include results of mediation requests.
   ResponseInfo responseInfo = error.GetResponseInfo();
   Debug.Log("Response info: " + responseInfo.ToString());
}

Bạn có thể sử dụng thông tin này để xác định chính xác hơn nguyên nhân khiến quảng cáo không tải được. Cụ thể, đối với các lỗi thuộc miền com.google.admob trên iOS và com.google.android.gms.ads trên Android, bạn có thể tra cứu GetMessage() trong bài viết này trên trung tâm trợ giúp để biết nội dung giải thích chi tiết hơn và các hành động có thể thực hiện để giải quyết vấn đề.