Rewarded Interstitial Ads

Rewarded interstitial is a type of incentivized ad format that lets you offer rewards for ads that appear automatically during natural app transitions. Unlike rewarded ads, users aren't required to opt-in to view a rewarded interstitial. This guide shows how to integrate rewarded interstitial ads from AdMob into a Flutter app.

Prerequisites

  • Flutter plugin 1.1.0 or higher.
  • Complete Get Started. Your Flutter app should already have the Google Mobile Ads Flutter plugin imported.

Always test with test ads

When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account.

The easiest way to load test ads is to use our dedicated test ad unit ID for rewarded interstitial ads:

The test ad units are configured to return test ads for every request, and you're free to use them in your own apps while coding, testing, and debugging. Just make sure you replace them with your own ad unit IDs before publishing your app.

Load an ad

Loading a RewardedInterstitialAd requires an adUnitId, an AdRequest, and a RewardedInterstitialAdLoadCallback. The following example loads a rewarded interstitial ad:

RewardedInterstitialAd.load(
  adUnitId: '<ad unit id>',
  adRequest: AdRequest(),
  rewardedInterstitialAdLoadCallback: RewardedInterstitialAdLoadCallback(
    onAdLoaded: (RewardedInterstitialAd ad) {
      print('$ad loaded.');
      // Keep a reference to the ad so you can show it later.
      this._rewardedInterstitialAd = ad;
    },
    onAdFailedToLoad: (LoadAdError error) {
      print('RewardedInterstitialAd failed to load: $error');
    },
);

Rewarded interstitial ad events

Through the use of FullScreenContentCallback, you can listen for lifecycle events, such as when the ad is shown or dismissed. Set RewardedInterstitialAd.fullScreenContentCallback before showing the ad to receive notifications for these events. This example implements each method and logs a message to the console:

rewardedInterstitialAd.fullScreenContentCallback = FullScreenContentCallback(
  onAdShowedFullScreenContent: (RewardedInterstitialAd ad) =>
     print('$ad onAdShowedFullScreenContent.'),
  onAdDismissedFullScreenContent: (RewardedInterstitialAd ad) {
    print('$ad onAdDismissedFullScreenContent.');
    ad.dispose();
  },
  onAdFailedToShowFullScreenContent: (RewardedInterstitialAd ad, AdError error) {
    print('$ad onAdFailedToShowFullScreenContent: $error');
    ad.dispose();
  },
  onAdImpression: (RewardedInterstitialAd ad) => print('$ad impression occurred.'),
);

Display ad

A RewardedInterstitialAd is displayed as an Overlay on top of all app content and is statically placed; thus, it can't be added to the Flutter widget tree. You can choose when to show the ad by calling show(). RewardedInterstitialAd.show() takes an OnUserEarnedRewardCallback, which is invoked when the user earns a reward. Be sure to implement this and reward the user for watching an ad.

myRewardedInterstitial.show(onUserEarnedReward: (RewardedInterstitialAd ad, RewardItem rewardItem) {
  // Reward the user for watching an ad.
});

Once show() is called, an Ad displayed this way can't be removed programmatically and requires user input. A RewardedInterstitialAd can only be shown once. Subsequent calls to show will trigger onAdFailedToShowFullScreenContent.

Once an ad has called load(), it must call dispose() when access to it is no longer needed. The best practice for when to call dispose() is in the FullScreenContentCallback.onAdDismissedFullScreenContent and FullScreenContentCallback.onAdFailedToShowFullScreenContent callbacks.

That's it! Your app is now ready to display rewarded interstitial ads.