Ad error codes - bdlukaa/native_admob_flutter GitHub Wiki
Handling errors
Errors can be handled by any ads by listening to their events
Interstitial, Rewarded and App Open Ads
ad.onEvent.listen((e) {
final event = e.keys.first;
switch (event) {
case InterstitialAdEvent.loadFailed:
final error = e.values.first;
print('load failed: ${error.code}');
break;
case InterstitialAdEvent.showFailed:
final error = e.values.first;
print('show failed: ${error.code}');
break;
default:
break;
}
});
Instead of InterstitialAdEvent, you can use:
RewardedAdEventfor Rewarded Ads and Rewarded Interstitial AdsAppOpenEventfor App Open Ads
Native and Banner Ads
You must attach a controller to the ad widget.
final controller = NativeAdController(); /* or BannerAdController(), if you're using banner ad */
Widget build(BuildContext context) {
return NativeAd(controller: controller); /* or BannerAd() */
}
ad.onEvent.listen((e) {
final event = e.keys.first;
switch (event) {
case NativeAdEvent.loadFailed: /* or BannerAdEvent */
final error = e.values.first;
print('load failed: ${error.code}');
break;
default:
break;
}
});
Load error codes
| Code | Name | Description |
|---|---|---|
| -1 | Timeout reached | The load timeout was achieved |
| 0 | Internal error | Something happened internally, usually, an invalid response is received from the server |
| 1 | Invalid request | The request was invalid, usually, the ad unit ID was incorrect |
| 2 | Network error | The request was unsuccessful due to network connectivity |
| 3 | No fill | The request was successful, but no ad was returned due to lack of ad inventory |
Show error codes (from full-screen ads)
These errors usually come from Rewarded, Interstitial and App Open ads when trying to show.
| Code | Name | Description |
|---|---|---|
| 0 | Internal Error | Indicates something unexpected happened internally. |
| 1 | Ad reused | Indicates the ad has already been shown. |
| 2 | Ad not ready | Indicates the ad is not ready to be shown |
| 3 | App not in foreground | The app must be in foreground so it can be shown |
List of errors for:
NOTE: Error codes may differ on different platforms