Interstitial Ad

1. Basic Requirements

  • Add ADX Flutter SDK to your project.

  • Use the ADX Ad Unit ID issued for Interstitial Ad.

  • Before requesting an ad, SDK initialization must be done first.

    • SDK initialization should be called only once when the app launches and ad requests should be made after SDK initialization is complete.

2. Implementation

  1. If the app is distributed on both Android and iOS, enter the Ad Unit ID issued for each platform.

  2. Register the necessary callbacks.

  3. Call AdxSdk.loadInterstitial() to load the ad.

  4. Call AdxSdk.destroyInterstitial() when disposing of the ad object.

String adUnitId = Platform.isAndroid ? "<ANDROID_ADX_INTERSTITIAL_AD_UNIT_ID>" : "<IOS_ADX_INTERSTITIAL_AD_UNIT_ID>";

AdxSdk.setInterstitialListener(InterstitialAdListener(
  onAdLoaded: (){
  },
  onAdError: (int errorCode){
  },
  onAdImpression: (){
  },
  onAdClicked: (){
  },
  onAdClosed: (){
  },
  onAdFailedToShow: (){
  })
);

AdxSdk.loadInterstitial(adUnitId);
  • Once the ad is loaded, call showInterstitial() to display the ad.

bool isLoaded = (await AdxSdk.isInterstitialLoaded(adUnitId))!;
if (isLoaded) {
    AdxSdk.showInterstitial(adUnitId);
}
  • Call destroyInterstitial() when disposing of the ad object.

@override
void dispose() {
  super.dispose();
  AdxSdk.destroyInterstitial(adUnitId);
}

3. Callback

You can receive specific events. Implement as needed.

class InterstitialAdListener {

  void Function() onAdLoaded;
  void Function(int errorCode) onAdError;
  void Function() onAdImpression;
  void Function() onAdClicked;
  void Function() onAdClosed;
  void Function() onAdFailedToShow;

  InterstitialAdListener({
      required this.onAdLoaded,
      required this.onAdError,
      required this.onAdImpression,
      required this.onAdClicked,
      required this.onAdClosed,
      required this.onAdFailedToShow
  });
}

Last updated

Was this helpful?