Geniee Mediation Integration For iOS DoubleClick english - unigeniee/Geniee-iOS-SDK GitHub Wiki
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 feature, DoubleClick's Video Rewards will display video advertisements for each ad network with Geniee's mediation.
Add the following to Podfile.
pod 'Google-Mobile-Ads-SDK'
Add the following to Podfile.
pod 'Geniee-DFP-Mediation-Adapter'
About manual installation procedure
Download GNAdDFPRewardMediationAdapter.Copy GNAdDFPRewardMediationAdapter.framework to the project by drag-and-drop.
Select the project from the navigator area, then select "TARGET" -> "General".
Add "GNAdDFPRewardMediationAdapter.framework" to "Embedded Binaries".
- Select "Pods/***.xcconfig" from the navigator area.
Delete -framework "GoogleMobileAds" from "OTHER_LDFLAGS". - Select a project from the navigator area, then select "TARGETS" -> "Build Settings".
Delete "GoogleMobileAds" from "Other Linker Flags".
For installation of Geniee SDK, see the start guide.
For video rewarding, it is necessary to set SDK and adapter for each ad network. Please refer to the introduction method from the link of the ad network from the following.
Ad network | Version |
---|---|
maio | 1.4.0 |
AppLovin | 5.1.1 |
Unity Ads | 2.3.0 |
AdColony | 3.3.5 |
CAReward | 2.3.1 |
Tapjoy | 12.0.0 |
Vungle | 6.2.0 |
Nend | 5.0.2 |
AMoAd | playable1.0.0 |
Implement GADRewardBasedVideoAdDelegate.
- ObjectiveC
About Delegate implementation
Add import and Delegate to the header file.
例:ViewController.h
#import <GoogleMobileAds/GoogleMobileAds.h>
@interface ViewController <GADRewardBasedVideoAdDelegate>
Set Delegate
例:Viewcontroller.m
[GADRewardBasedVideoAd sharedInstance].delegate = self;
To receive notification from the SDK, implement the method of GADRewardBasedVideoAdDelegate.
例:Viewcontroller.m
// Tells the delegate that the reward based video ad has rewarded the user.
- (void)rewardBasedVideoAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd didRewardUserWithReward:(GADAdReward *)reward {
}
// Tells the delegate that the reward based video ad failed to load.
- (void)rewardBasedVideoAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd didFailToLoadWithError:(NSError *)error {
}
// Tells the delegate that a reward based video ad was received.
- (void)rewardBasedVideoAdDidReceiveAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
}
// Tells the delegate that the reward based video ad opened.
- (void)rewardBasedVideoAdDidOpen:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
}
// Tells the delegate that the reward based video ad started playing.
- (void)rewardBasedVideoAdDidStartPlaying:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
}
// Tells the delegate that the reward based video ad completed playing.
- (void)rewardBasedVideoAdDidCompletePlaying:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
}
// Tells the delegate that the reward based video ad closed.
- (void)rewardBasedVideoAdDidClose:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
}
// Tells the delegate that the reward based video ad will leave the application.
- (void)rewardBasedVideoAdWillLeaveApplication:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
}
- Swift
About Delegate implementation
Set Delegate.GADRewardBasedVideoAd.sharedInstance().delegate = self
To receive notification from the SDK, implement the method of GADRewardBasedVideoAdDelegate.
extension ViewController : GADRewardBasedVideoAdDelegate {
// Tells the delegate that the reward based video ad has rewarded the user.
func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd, didRewardUserWith reward: GADAdReward) {
}
// Tells the delegate that the reward based video ad failed to load.
func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd, didFailToLoadWithError error: Error) {
}
// Tells the delegate that a reward based video ad was received.
func rewardBasedVideoAdDidReceive(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
}
// Tells the delegate that the reward based video ad opened.
func rewardBasedVideoAdDidOpen(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
}
// Tells the delegate that the reward based video ad started playing.
func rewardBasedVideoAdDidStartPlaying(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
}
// Tells the delegate that the reward based video ad completed playing.
func rewardBasedVideoAdDidCompletePlaying(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
}
// Tells the delegate that the reward based video ad closed.
func rewardBasedVideoAdDidClose(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
}
// Tells the delegate that the reward based video ad will leave the application.
func rewardBasedVideoAdWillLeaveApplication(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
}
}
Set load request to UnitID and request video ad load.
Note:
If you want to display another video ad after a single video ad appears, you will need to run loadRequest again.
- ObjectiveC
DFPRequest *request = [DFPRequest request];
[[GADRewardBasedVideoAd sharedInstance] loadRequest:request withAdUnitID:@"YOUR_UNIT_ID"];
- Swift
let request :DFPRequest = DFPRequest()
GADRewardBasedVideoAd.sharedInstance().load(request, withAdUnitID: "YOUR_UNIT_ID")
Make sure the video ad is ready and display the video ad.
- ObjectiveC
if ([[GADRewardBasedVideoAd sharedInstance] isReady]) {
[[GADRewardBasedVideoAd sharedInstance] presentFromRootViewController:self];
}
- Swift
if GADRewardBasedVideoAd.sharedInstance().isReady == true {
GADRewardBasedVideoAd.sharedInstance().present(fromRootViewController: self)
}
If DoubleClick's video reward fails to load, you can prevent the spill of ads by calling Geniee SDK. The implementation procedure is as follows.
Import GNSVideoReward of Geniee SDK.
- ObjectiveC
Import the header file and add Delegate.
Example:ViewController.h
#import <GNAdSDK/GNSRequest.h>
#import <GNAdSDK/GNSRewardVideoAdDelegate.h>
@interface ViewController <GADRewardBasedVideoAdDelegate, GNSRewardVideoAdDelegate>
- Swift
Add a header file with the following contents.
#import <GNAdSDK/GNSRequest.h>
#import <GNAdSDK/GNSRewardVideoAdDelegate.h>
Select the project from the navigator area, then select "TARGET" -> "Build Settings".
Add path of the header file created above to "Objective-C Bridging Header".
implementation of GNSRewardVideoAdDelegate.
- ObjectiveC
About Delegate implementation
Set Delegate.[GNSRewardVideoAd sharedInstance].delegate = self;
To receive notification from the SDK, implement the method of GNSRewardVideoAdDelegate.
// Tells the delegate that the reward based video ad failed to load.
- (void)rewardVideoAd:(GNSRewardVideoAd *)rewardVideoAd didFailToLoadWithError:(NSError *)error {
}
// Tells the delegate that a reward based video ad was received.
- (void)rewardVideoAdDidReceiveAd:(GNSRewardVideoAd *)rewardVideoAd
{
}
// Tells the delegate that the reward based video ad started playing.
- (void)rewardVideoAdDidStartPlaying:(GNSRewardVideoAd *)rewardVideoAd {
}
// Tells the delegate that the reward based video ad closed.
- (void)rewardVideoAdDidClose:(GNSRewardVideoAd *)rewardVideoAd {
}
// Tells the delegate that the reward based video ad has rewarded the user.
- (void)rewardVideoAd:(GNSRewardVideoAd *)rewardVideoAd didRewardUserWithReward:(GNSAdReward *)reward {
}
- Swift
About Delegate implementation
Set Delegate.GNSRewardVideoAd.sharedInstance().delegate = self
To receive notification from the SDK, implement the method of GNSRewardVideoAdDelegate.
extension ViewController : GNSRewardVideoAdDelegate {
// Tells the delegate that a reward based video ad was received.
func rewardVideoAdDidReceive(_ rewardVideoAd: GNSRewardVideoAd!) {
}
// Tells the delegate that the reward based video ad has rewarded the user.
func rewardVideoAd(_ rewardVideoAd: GNSRewardVideoAd!, didRewardUserWith reward: GNSAdReward!) {
}
// Tells the delegate that the reward based video ad failed to load.
func rewardVideoAd(_ rewardVideoAd: GNSRewardVideoAd!, didFailToLoadWithError error: Error!) {
}
// Tells the delegate that the reward based video ad started playing.
func rewardVideoAdDidStartPlaying(_ rewardVideoAd: GNSRewardVideoAd!) {
}
// Tells the delegate that the reward based video ad closed.
func rewardVideoAdDidClose(_ rewardVideoAd: GNSRewardVideoAd!) {
}
}
Implement the load method of Geniee SDK animation reward in the method called when DoubleClick 's Load fails.
Specify the Zone ID in the load request.
If you want to show another movie after the completion of playback of one movie, you need to make a load request again.
- ObjectiveC
- (void)rewardBasedVideoAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd didFailToLoadWithError:(NSError *)error {
GNSRequest *request = [GNSRequest request];
[[GNSRewardVideoAd sharedInstance] loadRequest:request
withZoneID:@"YOUR_ZONE_ID"];
}
- Swift
func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd, didFailToLoadWithError error: Error) {
let request = GNSRequest()
GNSRewardVideoAd.sharedInstance().load(request, withZoneID: "YOUR_ZONE_ID")
}
In the order of DoubleClick → Geniee SDK, check whether load is completed, and show movies by show method.
Please be sure to execute show after running DoubleClick's Load.
- ObjectiveC
if ([[GADRewardBasedVideoAd sharedInstance] isReady]) {
[[GADRewardBasedVideoAd sharedInstance] presentFromRootViewController:self];
} else if ([[GNSRewardVideoAd sharedInstance] canShow]) {
[[GNSRewardVideoAd sharedInstance] show:self];
}
- Swift
if GADRewardBasedVideoAd.sharedInstance().isReady == true {
rewardBasedVideo?.present(fromRootViewController: self)
} else if GNSRewardVideoAd.sharedInstance().canShow() {
GNSRewardVideoAd.sharedInstance().show(self)
}
To maximize revenue with video ads, it is important to remunerate video ad viewers. GNSAdReward includes the following items.
- reward.type:SSP currency type setting
- reward.amount:SSP currency amount setting
Use didRewardUserWithReward callback method to reward users.
- ObjectiveC
- (void)rewardVideoAd:(GNSRewardVideoAd *)rewardVideoAd didRewardUserWithReward:(GNSAdReward *)reward {
NSLog(@"ViewController: Reward received type=%@, amount=%lf"
,reward.type
,[reward.amount doubleValue]);
}
- Swift
func rewardVideoAd(_ rewardVideoAd: GNSRewardVideoAd!, didRewardUserWith reward: GNSAdReward!) {
print("ViewController: Reward received type=" + reward.type + " , amount=\(reward.amount.doubleValue)")
}