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

Creating a rewarded interstitial ad

Bruno D'Luka edited this page Mar 15, 2021 · 2 revisions

Rewarded interstitial is a type of incentivized ad format that allows 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. Learn more

Example

A user playing a game has just completed a level. While the next level loads, the user is prompted that an ad will begin in a few seconds and the reward for watching the ad is an extra heart. The user has the option to close the ad.

After a few seconds, the ad begins with a countdown that lets the user know how much time is left until they receive the reward. If the user clicks to exit the ad, a prompt appears to warn about the loss of the reward. The user must confirm that they want to exit the ad before the ad closes.

Rewarded Interstitial Example

Before displaying a rewarded interstitial ad to users, you must present the user with an introduction screen that includes the following:

  • Clear reward messaging that incentivizes users to view the ad
  • A clear, unobstructed option to skip the ad before it starts
  • Sufficient time for the user to understand the reward and opt-out if they don’t want to view the ad

You can specify the reward values associated with the ad units in your app and set different rewards for different ad units. Users will receive the reward for interacting with the ad without needing to install anything.

Video ad type

  • Sound Controls:

    • Volume control based on the device volume (not app-specific volume controls)
    • Mute icon support (Android only)
  • Closeable video ad:

    • Clicking on the X button will generate a prompt asking if the user wishes to close the ad
    • The user is warned that they will lose the reward if the ad is closed
  • Countdown timer:

    • Lets the user know how much time is left until they receive the reward
  • Delayed install:

    • The user is brought to the appropriate app store on completed view
  • End Card (optional install):

    • The user receives a reward for viewing the video ad (no need to install)
    • The install button turns green on video completion
    • Clicking the button takes the user directly to the appropriate app store

Interactive ad type

You can optionally include interactive ads in your rewarded ad units.

  • Playable ads:

    • Click-to-download ads that let the user try out a game by playing it within the ad unit context.
    • Afterward, the user is offered the opportunity to download the app.
  • Survey ads:

    • Asks the user a question.
    • After answering, the user receives a reward.

Creating an ad object

To create a rewarded interstitial ad, use the class RewardedInterstitialAd:

// You can set the unit id on the constructor
RewardedInterstitialAd rewardedInterstitialAd = RewardedInterstitialAd(/* unitId: MobileAds.rewardedInterstitialAdVideoTestUnitId */);

A single InterstitialAd object can be used to request and display multiple interstitial ads, so you only need to construct it once.

Load the ad

In order to show an ad, it needs to be loaded first. You can use load() to load the ad:

rewardedInterstitialAd.load();

You can load an ad right when you initalize the ad:

RewardedInterstitialAd rewardedInterstitialAd = RewardedInterstitialAd()..load(timeout: Duration(minutes: 1));

Show the ad

Before displaying a rewarded interstitial ad to users, you must present the user with an intro screen that provides clear reward messaging and an option to skip the ad before it starts. Learn more. To show a rewarded interstitial, use the isAvailable method to verify that it's done loading, then call show(). The rewarded interstitial ad from the previous code example could be shown in a button's onPressed like this:

FlatButton(
  child: Text('Open rewarded interstitial ad'),
  onPressed: () async {
    // Load only if not loaded
    if (!rewardedInterstitialAd.isAvailable) await rewardedInterstitialAd.load();
    if (rewardedInterstitialAd.isAvailable) rewardedInterstitialAd.show();
  },
),

Listening to events

To further customize the behavior of your ad, you can hook onto a number of events in the ad's lifecycle: loading, opening, closing, and so on. You can listen for these events using rewardedInterstitialAd.onEvent.listen((_) {...}):

rewardedInterstitialAd.onEvent.listen((e) {
  final event = e.keys.first;
  switch (event) {
    case RewardedAdEvent.loading:
      print('loading');
      break;
    case RewardedAdEvent.loaded:
      print('loaded');
      break;
    case RewardedAdEvent.loadFailed:
      final errorCode = e.values.first;
      print('load failed $errorCode');
      break;
    case RewardedAdEvent.opened:
      print('ad opened');
      break;
    case RewardedAdEvent.closed:
      print('ad closed');
      break;
    case RewardedAdEvent.earnedReward:
      final reward = e.values.first;
      print('earned reward: $reward');
      break;
    case RewardedAdEvent.showFailed:
      final errorCode = e.values.first;
      print('show failed $errorCode');
      break;
    default:
       break;
  }
});

Using the listener to reload

RewardedAdEvent.closed is a handy place to load a new interstitial after displaying the previous one:

rewardedInterstitialAd.onEvent.listen((e) {
  final event = e.keys.first;
  switch (event) {
    case RewardedAdEvent.closed:
      rewardedAd = RewardedAd.load();
      break;
    default:
       break;
  }
});

Do NOT show a new ad in RewardedAdEvent.closed, because it'll become infinite.