Geniee Mediation Interstitial Integration For iOS DoubleClick english - unigeniee/Geniee-iOS-SDK GitHub Wiki
Fullscreen interstitial ad is an advertisement 「content」 By using this feature, DoubleClick's Fullscreen Interstitial will display interstitial 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 GNAdDFPFullscreenInterstitialMediationAdapter.GNAdDFPFullscreenInterstitialMediationAdapter
Copy GNAdDFPFullscreenInterstitialMediationAdapter.framework to the project by drag-and-drop.
Select the project from the navigator area, then select "TARGET" -> "General".
Add "GNAdDFPFullscreenInterstitialMediationAdapter.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 fullscreen interstitial, 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.3.0 |
AppLovin | 5.0.1 |
Nend | 5.0.2 |
Zucks | 4.7.8 |
Tapjoy | 12.0.0 |
UnityAds | 2.3.0 |
Vungle | 6.2.0 |
i-mobile | 2.0.29 |
Implement GADInterstitialDelegate.
- ObjectiveC
About Delegate implementation
Add import and Delegate to the header file.
例:ViewController.h
#import <GoogleMobileAds/GoogleMobileAds.h>
@interface ViewController <GADInterstitialDelegate>
Set Delegate
例:Viewcontroller.m
self.interstitial = [[DFPInterstitial alloc]initWithAdUnitID:@"UnitId"];
self.interstitial.delegate = self;
To receive notification from the SDK, implement the method of GADInterstitialDelegate.
例:Viewcontroller.m
/// Tells the delegate an ad request succeeded.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad
{
}
/// Tells the delegate an ad request failed.
- (void)interstitial:(DFPInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error {
}
/// Tells the delegate that an interstitial will be presented.
- (void)interstitialWillPresentScreen:(DFPInterstitial *)ad {
}
/// Tells the delegate the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(DFPInterstitial *)ad {
}
/// Tells the delegate the interstitial had been animated off the screen.
- (void)interstitialDidDismissScreen:(DFPInterstitial *)ad {
}
/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
- (void)interstitialWillLeaveApplication:(DFPInterstitial *)ad {
}
- Swift
About Delegate implementation
Set Delegate.interstitial = DFPInterstitial(adUnitID: "UnitId")
interstitial.delegate = self
To receive notification from the SDK, implement the method of GADInterstitialDelegate.
extension ViewController : GADInterstitialDelegate {
/// Tells the delegate an ad request succeeded.
func interstitialDidReceiveAd(_ ad: DFPInterstitial) {
}
/// Tells the delegate an ad request failed.
func interstitial(_ ad: DFPInterstitial, didFailToReceiveAdWithError error: GADRequestError) {
}
/// Tells the delegate that an interstitial will be presented.
func interstitialWillPresentScreen(_ ad: DFPInterstitial) {
}
/// Tells the delegate the interstitial is to be animated off the screen.
func interstitialWillDismissScreen(_ ad: DFPInterstitial) {
}
/// Tells the delegate the interstitial had been animated off the screen.
func interstitialDidDismissScreen(_ ad: DFPInterstitial) {
}
/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
func interstitialWillLeaveApplication(_ ad: DFPInterstitial) {
}
}
Set load request to UnitID and request interstitial ad load.
Note:
If you want to display another interstitial ad after a single interstitial ad appears, you will need to run loadRequest again.
- ObjectiveC
DFPRequest *request = [DFPRequest request];
[self.interstitial loadRequest:request];
- Swift
let request = DFPRequest()
interstitial.load(request)
Make sure the ad has ready to display.
- ObjectiveC
if (self.interstitial.isReady) {
[self.interstitial presentFromRootViewController:self];
}
- Swift
if interstitial.isReady {
interstitial.present(fromRootViewController: self)
}
If DoubleClick's Fullscreen Interstitial fails to load, you can prevent the spill of ads by calling Geniee SDK. The implementation procedure is as follows.
Import GNSFullscreenInterstitialAd of Geniee SDK.
- ObjectiveC
Import the header file and add Delegate.
Example:ViewController.h
#import <GNAdSDK/GNSRequest.h>
#import <GNAdSDK/GNSFullscreenInterstitialAdDelegate.h>
@interface ViewController <GADInterstitialDelegate, GNSFullscreenInterstitialAdDelegate>
- Swift
Add a header file with the following contents.
#import <GNAdSDK/GNSRequest.h>
#import <GNAdSDK/GNSFullscreenInterstitialAdDelegate.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 GNSFullscreenInterstitialAdDelegate.
- ObjectiveC
About Delegate implementation
Set Delegate.[GNSFullscreenInterstitialAd sharedInstance].delegate = self;
To receive notification from the SDK, implement the method of GNSFullscreenInterstitialAdDelegate.
/// Tells the delegate that the interstitial ad failed to load.
- (void)fullscreenInterstitial:(GNSFullscreenInterstitialAd *)fullscreenInterstitialAd
didFailToLoadWithError:(NSError *)error {
}
/// Tells the delegate that the interstitial ad loaded.
- (void)fullscreenInterstitialDidReceiveAd:(GNSFullscreenInterstitialAd *)fullscreenInterstitialAd {
}
/// Tells the delegate that the interstitial ad started showing.
(void)fullscreenInterstitialWillPresentScreen:(GNSFullscreenInterstitialAd *)fullscreenInterstitialAd {
}
/// Tells the delegate that the interstitial ad closed.
- (void)fullscreenInterstitialAdDidClose:(GNSFullscreenInterstitialAd *)fullscreenInterstitialAd {
}
- Swift
About Delegate implementation
Set Delegate.GNSFullscreenInterstitialAd.sharedInstance().delegate = self
To receive notification from the SDK, implement the method of GNSFullscreenInterstitialAdDelegate.
extension ViewController : GNSFullscreenInterstitialAdDelegate {
// Tells the delegate that a interstitial ad was received.
func fullscreenInterstitialDidReceiveAd(_ fullscreenInterstitialAd: GNSFullscreenInterstitialAd!) {
}
// Tells the delegate that the interstitial ad failed to load.
func fullscreenInterstitial(_ fullscreenInterstitialAd: GNSFullscreenInterstitialAd!, didFailToLoadWithError error: Error!) {
}
// Tells the delegate that the interstitial ad started showing.
func fullscreenInterstitialWillPresentScreen(_ fullscreenInterstitialAd: GNSFullscreenInterstitialAd!) {
}
// Tells the delegate that the interstitial ad closed.
func fullscreenInterstitialAdDidClose(_ fullscreenInterstitialAd: GNSFullscreenInterstitialAd!) {
}
}
Implement the load interstitial ad of Geniee SDK 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)interstitial:(DFPInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error {
GNSRequest *request = [GNSRequest request];
[[GNSFullscreenInterstitialAd sharedInstance] loadRequest:request
withZoneID:@"YOUR_SSP_ZONE_ID"];
}
- Swift
func interstitial(_ ad: DFPInterstitial, didFailToReceiveAdWithError error: GADRequestError) {
let request = GNSRequest()
GNSFullscreenInterstitialAd.sharedInstance().load(request, withZoneID: "YOUR_ZONE_ID")
}
In the order of DoubleClick → Geniee SDK, check whether load is completed, and show ad by show method.
Please be sure to execute show after running DoubleClick's Load.
- ObjectiveC
if (self.interstitial.isReady) {
[self.interstitial presentFromRootViewController:self];
} else if ([[GNSFullscreenInterstitialAd sharedInstance] canShow]) {
[[GNSFullscreenInterstitialAd sharedInstance] show:self];
}
- Swift
if interstitial.isReady {
interstitial.present(fromRootViewController: self)
} else if GNSFullscreenInterstitialAd.sharedInstance().canShow() {
GNSFullscreenInterstitialAd.sharedInstance().show(self)
}