Geniee Mediation Interstitial Integration For iOS DoubleClick - unigeniee/Geniee-iOS-SDK GitHub Wiki
全画面インタースティシャル広告とは、。。。。 広告フォーマットです。
本機能を使用する事により、DoubleClickの全画面インタースティシャルで、Genieeのメディエーション機能により各アドネットワークの全画面インタースティシャル広告を表示します。
Podfileに以下の行を記述します。
pod 'Google-Mobile-Ads-SDK'
Podfileに以下を記述します。
pod 'Geniee-DFP-FullscreenInterstitial-Mediation-Adapter'
手動導入手順はこちら
GNAdDFPFullscreenInterstitialMediationAdapter をダウンロードします。GNAdDFPFullscreenInterstitialMediationAdapter
GNAdDFPFullscreenInterstitialMediationAdapter.framework をドラッグアンドドロップでプロジェクトにコピーして追加してください。
ナビゲータエリアよりプロジェクトを選択し、"TARGET" -> "General" を選択する。
"Embedded Binaries" へ "GNAdDFPFullscreenInterstitialMediationAdapter.framework" を追加する。
- ナビゲータエリアより"Pods/***.xcconfig" を選択する。
"OTHER_LDFLAGS" から -framework "GoogleMobileAds" を削除する。 - ナビゲータエリアよりプロジェクトを選択し、"TARGETS" -> "Build Settings" を選択する。
"Other Linker Flags" から "GoogleMobileAds" を削除する。
Geniee SDK のインストールは、下記スタートガイドから行ってください。
全画面インタースティシャルでは、配信で使用するアドネットワーク毎のSDKとアダプターの設定が必要です。 以下よりアドネットワークのリンクから導入方法を参照して下さい。
アドネットワーク | 検証済みバージョン |
---|---|
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 |
GADInterstitialDelegateを実装します。
- ObjectiveC
Delegate実装手順はこちら
ヘッダーファイルへimport、Delegateの記述を追加します。
例:ViewController.h
#import <GoogleMobileAds/GoogleMobileAds.h>
@interface ViewController <GADInterstitialDelegate>
Delegateを指定します。
例:Viewcontroller.m
self.interstitial = [[DFPInterstitial alloc]initWithAdUnitID:@"UnitId"];
self.interstitial.delegate = self;
SDKから通知を受け取る為の、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
Delegate実装手順はこちら
Delegateを指定します。interstitial = DFPInterstitial(adUnitID: "UnitId")
interstitial.delegate = self
SDKから通知を受け取る為の、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) {
}
ロードリクエストにUnitIDを指定して、インタースティシャル広告ロードリクエストします。
Note:
1つのインタースティシャル広告が表示された後に別のインタースティシャル広告を表示する場合は、もう一度loadRequestを実行する必要があります。
- ObjectiveC
DFPRequest *request = [DFPRequest request];
[self.interstitial loadRequest:request];
- Swift
let request = DFPRequest()
interstitial.load(request)
インタースティシャル広告が準備完了であることを確認し、インタースティシャル広告を表示します。
- ObjectiveC
if (self.interstitial.isReady) {
[self.interstitial presentFromRootViewController:self];
}
- Swift
if interstitial.isReady {
interstitial.present(fromRootViewController: self)
}
DoubleClickの全画面インタースティシャルがLoad失敗になった場合に、Geniee SDKを呼び出すことで、広告の空き枠を防ぐことができます。実装手順は以下の通りです。
Geniee SDKの GNSFullscreenInterstitialAd をインポートします。
- ObjectiveC
ヘッダーファイルをimportし、Delegateを追加します。
例:ViewController.h
#import <GNAdSDK/GNSRequest.h>
#import <GNAdSDK/GNSFullscreenInterstitialAdDelegate.h>
@interface ViewController ()<GADInterstitialDelegate, GNSFullscreenInterstitialAdDelegate>
- Swift
以下の内容のヘッダーファイルを追加します。
#import <GNAdSDK/GNSRequest.h>
#import <GNAdSDK/GNSFullscreenInterstitialAdDelegate.h>
ナビゲータエリアよりプロジェクトを選択し、"TARGET" -> "Build Settings" を選択する。
"Objective-C Bridging Header" へ 上記で作成したヘッダーファイルのパスを追加する。
GNSFullscreenInterstitialAdDelegateを実装します。
- ObjectiveC
Delegate実装手順はこちら
Delegateを指定します。[GNSFullscreenInterstitialAd sharedInstance].delegate = self;
SDKから通知を受け取る為の、GNSFullscreenInterstitialAdDelegateのメソッドを実装します。
/// デリゲートで全画面インステ広告のロード失敗を定義します。
- (void)fullscreenInterstitial:(GNSFullscreenInterstitialAd *)fullscreenInterstitialAd
didFailToLoadWithError:(NSError *)error {
}
/// デリゲートで全画面インステ広告のロードを定義します。
- (void)fullscreenInterstitialDidReceiveAd:(GNSFullscreenInterstitialAd *)fullscreenInterstitialAd {
}
/// デリゲートで全画面インステ広告の再生開始を定義します。
(void)fullscreenInterstitialWillPresentScreen:(GNSFullscreenInterstitialAd *)fullscreenInterstitialAd {
}
/// デリゲートで全画面インステ広告が閉じられることを定義します。
- (void)fullscreenInterstitialAdDidClose:(GNSFullscreenInterstitialAd *)fullscreenInterstitialAd {
}
- Swift
Delegate実装手順はこちら
Delegateを指定します。GNSFullscreenInterstitialAd.sharedInstance().delegate = self
SDKから通知を受け取る為の、GNSFullscreenInterstitialAdDelegateのメソッドを実装します。
extension ViewController : GNSFullscreenInterstitialAdDelegate {
// インタースティシャル広告が受信された事を通知するデリゲート.
func fullscreenInterstitialDidReceiveAd(_ fullscreenInterstitialAd: GNSFullscreenInterstitialAd!) {
}
// ロード失敗を通知するデリゲート.
func fullscreenInterstitial(_ fullscreenInterstitialAd: GNSFullscreenInterstitialAd!, didFailToLoadWithError error: Error!) {
}
// インタースティシャル広告の再生開始を通知するデリゲート.
func fullscreenInterstitialWillPresentScreen(_ fullscreenInterstitialAd: GNSFullscreenInterstitialAd!) {
}
// インタースティシャル広告が終了した事を通知するデリゲート.
func fullscreenInterstitialAdDidClose(_ fullscreenInterstitialAd: GNSFullscreenInterstitialAd!) {
}
}
DoubleClickのLoadが失敗した場合に呼び出されるメソッドにGeniee SDK全画面インタースティシャルのloadメソッドを実装します。
ロードリクエストにZoneIDを指定します。
1つのインタースティシャルの再生完了後に別のインタースティシャルを見せる場合、再びロードリクエストを行う必要があります。
- 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")
}
DoubleClick → Geniee SDKの順で、loadが完了しているかを確認し、showメソッドでインタースティシャルを表示します。
showは必ずDoubleClickの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)
}