Skip to content
This repository has been archived by the owner on Mar 12, 2022. It is now read-only.

Ad error codes

Bruno D'Luka edited this page Apr 20, 2021 · 5 revisions

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:

  • RewardedAdEvent for Rewarded Ads and Rewarded Interstitial Ads
  • AppOpenEvent for 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;
  }
});
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

Learn more

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