RewardedVideo Ad of Google Mobile Ads

Rewarded video ad is an advertisement format that displays video ads of approximate from 15 to 30 seconds and gives users items or points in the application.
By using this function, the reward advertisement of Geniee's video will be displayed with the video reward of Google AdMob / Google Ad Manager.

Preparation for implementation

Add GoogleMobileAds

Add the following to Podfile.

pod 'Google-Mobile-Ads-SDK'
1
Points to note when introducing GoogleMobileAds If you are introducing GoogleMobileAds, the app will crash if you do not include one of the following app ID information for Google AdMob / Google Ad Manager in Info.plist.
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-################~##########</string>
<key>SKAdNetworkItems</key>
  <array>
    <dict>
      <key>SKAdNetworkIdentifier</key>
      <string>cstr6suwn9.skadnetwork</string>
    </dict>
  </array>
1
2
3
4
5
6
7
8
9

Add GNAdGoogleMediationAdapter

Introduce with Cocoapods(Recommend)

Add the following to Podfile.

pod 'Geniee-Google-Mediation-Adapter'
1

Introduction with manual

About manual installation procedure Download GNAdGoogleMediationAdapter.

GNAdGoogleMediationAdapter

Copy GNAdGoogleMediationAdapter.xcframework to the project by drag-and-drop.

Select the project from the navigator area, then select "TARGET" -> "General".

Add "GNAdGoogleMediationAdapter.xcframework" to "Linked Framework and Libraries".

Add Geniee SDK

For installation of Geniee SDK, see the start guide.

Start guide

Implementation of rewarded video

  • Ad Manager

    By using the UnitID that set mediation on GoogleAdManager management screen, you can display the mediated RewardedVideo ads.
    For details on how to implement the RewardedVideo, please refer to the following site.
    How to implement RewardedVideo of GoogleAdManager

  • AdMob

    By using the UnitID that set mediation on GoogleAdMob management screen, you can display the mediated RewardedVideo ads.
    For details on how to implement the RewardedVideo, please refer to the following site.
    How to implement RewardedVideo of AdMob

Preparation for implementation

Import GoogleMobileAds.

  • ObjectiveC
    Import GoogleMobileAds and add Delegate.

例:ViewController.m

@import GoogleMobileAds;

@interface RewardNewViewController () <GADFullScreenContentDelegate>
1
2
3
  • Swift
    Nothing in particular.

Implement Delegate for ad display

Implement the GADFullScreenContentDelegate method to receive notifications from the SDK.

  • ObjectiveC
/// Tells the delegate that the rewarded ad was presented.
- (void)adDidPresentFullScreenContent:(id)ad {
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)ad:(id)ad didFailToPresentFullScreenContentWithError:(NSError *)error {
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)adDidDismissFullScreenContent:(id)ad {
}
1
2
3
4
5
6
7
8
9
10
11
  • Swift
extension ViewController : GADFullScreenContentDelegate {

    /// Tells the delegate that the rewarded ad was presented.
    func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
    }

    /// Tells the delegate that the rewarded ad was dismissed.
    func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
    }

    /// Tells the delegate that the rewarded ad failed to present.
    func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Load rewarded video ad

Implement the ad loading process. We recommend that you perform the loading process in advance. In the load request, specify the UnitID. (Get UnitId from the management screen of Google AdMob / Ad Manager)

If you want to show another video after playing one video, you need to make a load request again.

  • ObjectiveC
@property(nonatomic, strong) GADRewardedAd *rewardedAd;

- (void)loadReward {
    GAMRequest *request = [GAMRequest request];
    [GADRewardedAd loadWithAdUnitID:@"YOUR_UNIT_ID" request:request completionHandler:^(GADRewardedAd *ad, NSError *error) {
        if (error) {
            return;
        }
        self.rewardedAd = ad;
        self.rewardedAd.fullScreenContentDelegate = self;
    }];
}
1
2
3
4
5
6
7
8
9
10
11
12
  • Swift
var rewardedAd: GADRewardedAd!

func loadReward() {
    let request = GAMRequest()
    GADRewardedAd.load(withAdUnitID: "YOUR_UNIT_ID", request: request, completionHandler: { (ad, error) in
        if let error = error {
            return
        }
        self.rewardedAd = ad
        self.rewardedAd?.fullScreenContentDelegate = self
    })
}
1
2
3
4
5
6
7
8
9
10
11
12

Display rewarded video

Implement the display process of the advertisement. Please execute the display process after executing Load.

  • ObjectiveC
- (void)showReward {
    if (self.rewardedAd) {
        [self.rewardedAd presentFromRootViewController:self userDidEarnRewardHandler:^ {
            GADAdReward *reward = self.rewardedAd.adReward;
            // TODO: Reward the user.
            NSLog(@"rewardedAd:userDidEarnRewardHandler %@, amount %lf", reward.type, [reward.amount doubleValue]);
        }];
    }
}
1
2
3
4
5
6
7
8
9
  • Swift
func showReward() {
    if let ad = rewardedAd {
        ad.present(fromRootViewController: self, userDidEarnRewardHandler: {
            let reward = ad.adReward
            // TODO: Reward the user.
            print("rewardedAd:userDidEarnRewardHandler \(reward.type), amount \(reward.amount).")
        })
    }
}
1
2
3
4
5
6
7
8
9

Give users a reward

To maximize revenue with video ads, it is important to remunerate video ad viewers.
GADAdReward includes the following items.

  • reward.type:Currency type setting
  • reward.amount:Currency amount setting

To reward video ad viewers, use the callback method userDidEarnRewardHandler of the display processpresentFromRootViewController.

Last Updated: 3/18/2021, 4:14:05 PM