Quando un annuncio non viene caricato, viene chiamata una richiamata di errore che fornisce un oggetto LoadAdError.
Il seguente snippet di codice recupera le informazioni sugli errori quando un annuncio non viene caricato:
publicvoidOnAdFailedToLoad(LoadAdErrorerror){// Gets the domain from which the error came.stringdomain=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.intcode=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.stringmessage=error.GetMessage();// Gets the cause of the error, if available.AdErrorunderlyingError=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.ResponseInforesponseInfo=error.GetResponseInfo();Debug.Log("Response info: "+responseInfo.ToString());}
Queste informazioni possono essere utilizzate per determinare con maggiore precisione la causa del mancato caricamento dell'annuncio. In particolare, per gli errori nel dominio com.google.admob su
iOS e com.google.android.gms.ads su Android, è possibile cercare GetMessage() in questo articolo del Centro assistenza per una spiegazione più dettagliata
e le possibili azioni da intraprendere per risolvere il problema.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2026-05-31 UTC."],[],["When an ad fails to load, the `LoadAdError` object provides details via a callback. Key actions include retrieving the error's domain using `GetDomain()`, the error code with `GetCode()`, and a descriptive message via `GetMessage()`. The underlying cause is accessible with `GetCause()`. All data is also in the `ToString()` method. `GetResponseInfo()` offers insights, possibly regarding mediation. `GetMessage()` can be researched in a specific article to resolve the cause of the ad loading failure.\n"]]