Rewarded Ads: Publishers Get Started


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:

[[GADRewardBasedVideoAd sharedInstance] loadRequest:[GADRequest request]

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

Set up event notification

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

[GADRewardBasedVideoAd sharedInstance].delegate = self;

[[GADRewardBasedVideoAd sharedInstance] loadRequest:[GADRequest request]

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::

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

- (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:

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

Integration with Unity

For instructions on integrating rewarded video into a Unity project, see Rewarded Video.

Download the example

You can also download the rewarded video examples from GitHub to see rewarded video ads in action.

Download Swift example from GitHub Download Objective-C example from GitHub

Send feedback about...

SDK for AdX Users on iOS
Need help? Visit our support page.