Rewarded Video Ads

Rewarded video ads are full-screen video ads that users have the option of watching in full in exchange for in-app rewards.

This guide shows you how to integrate rewarded video ads from AdMob into an iOS app.

Prerequisites

Request rewarded video

GADRewardBasedVideoAd has a singleton design, so the following example shows a request to load an ad being made to the shared instance:

Swift

GADRewardBasedVideoAd.sharedInstance().load(GADRequest(),
    withAdUnitID: "ca-app-pub-3940256099942544/1712485313")

Objective-C

[[GADRewardBasedVideoAd sharedInstance] loadRequest:[GADRequest request]
                                       withAdUnitID:@"ca-app-pub-3940256099942544/1712485313"];

To allow videos to be preloaded, we recommend calling loadRequest: as early as possible (for example, in your app delegate's application:didFinishLaunchingWithOptions: method).

Always test with test ads

The sample code above contains an ad unit ID and you're free to request ads with it. It's been specially configured to return test ads rather than production ads for every request, which makes it safe to use.

However, once you register an app in the AdMob UI and create your own ad unit IDs for use in your app, you'll need to explicitly configure your device as a test device when you're developing. This is extremely important. Testing with real ads (even if you never tap on them) is against AdMob policy and can cause your account to be suspended. See Test Ads for information on how you can make sure you always get test ads when developing.

Set up event notifications

To set up event notification, insert the line shown in bold before your loadRequest: call:

Swift

GADRewardBasedVideoAd.sharedInstance().delegate = self
GADRewardBasedVideoAd.sharedInstance().load(GADRequest(),
          withAdUnitID: "ca-app-pub-3940256099942544/1712485313")

Objective-C

[GADRewardBasedVideoAd sharedInstance].delegate = self;
[[GADRewardBasedVideoAd sharedInstance] loadRequest:[GADRequest request]
                                       withAdUnitID:@"ca-app-pub-3940256099942544/1712485313"];

GADRewardBasedVideoAdDelegate notifies you of rewarded video lifecycle events. You are required to set the delegate prior to loading an ad. The most important event in this delegate is rewardBasedVideoAd:didRewardUserWithReward:, which is called when the user should be rewarded for watching a video. You may optionally implement other methods in this delegate.

Here is an example that logs each event available in GADRewardBasedVideoAdDelegate::

Swift

func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd,
    didRewardUserWith reward: GADAdReward) {
  print("Reward received with currency: \(reward.type), amount \(reward.amount).")
}

func rewardBasedVideoAdDidReceive(_ rewardBasedVideoAd:GADRewardBasedVideoAd) {
  print("Reward based video ad is received.")
}

func rewardBasedVideoAdDidOpen(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
  print("Opened reward based video ad.")
}

func rewardBasedVideoAdDidStartPlaying(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
  print("Reward based video ad started playing.")
}

func rewardBasedVideoAdDidClose(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
  print("Reward based video ad is closed.")
}

func rewardBasedVideoAdWillLeaveApplication(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
  print("Reward based video ad will leave application.")
}

func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd,
    didFailToLoadWithError error: Error) {
  print("Reward based video ad failed to load.")
}

Objective-C

- (void)rewardBasedVideoAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd
    didRewardUserWithReward:(GADAdReward *)reward {
  NSString *rewardMessage =
      [NSString stringWithFormat:@"Reward received with currency %@ , amount %lf",
          reward.type,
          [reward.amount doubleValue]];
  NSLog(rewardMessage);
}

- (void)rewardBasedVideoAdDidReceiveAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
  NSLog(@"Reward based video ad is received.");
}

- (void)rewardBasedVideoAdDidOpen:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
  NSLog(@"Opened reward based video ad.");
}

- (void)rewardBasedVideoAdDidStartPlaying:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
  NSLog(@"Reward based video ad started playing.");
}

- (void)rewardBasedVideoAdDidClose:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
  NSLog(@"Reward based video ad is closed.");
}

- (void)rewardBasedVideoAdWillLeaveApplication:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
  NSLog(@"Reward based video ad will leave application.");
}

- (void)rewardBasedVideoAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd
    didFailToLoadWithError:(NSError *)error {
  NSLog(@"Reward based video ad failed to load.");
}

Display rewarded video

It is a best practice to ensure a rewarded video ad has completed loading before attempting to display it. The isReady method indicates that a rewarded video ad request has been successfully fulfilled:

Swift

if GADRewardBasedVideoAd.sharedInstance().isReady == true {
  GADRewardBasedVideoAd.sharedInstance().present(fromRootViewController: self)
}

Objective-C

if ([[GADRewardBasedVideoAd sharedInstance] isReady]) {
  [[GADRewardBasedVideoAd sharedInstance] presentFromRootViewController:self];
}

Additional resources

Samples

Mobile Ads Garage video tutorials

Codelab

Next steps

Send feedback about...

AdMob for iOS
AdMob for iOS
Need help? Visit our support page.