Google Mobile Adsの全画面インタースティシャル広告
本機能を使用する事により、Google Mobile Adsの全画面インタースティシャルで、Genieeのメディエーション機能により各アドネットワークの全画面インタースティシャル広告を表示できます。
実装準備
GoogleMobileAds の追加
Podfileに以下の行を記述します。
pod 'Google-Mobile-Ads-SDK'
 GoogleMobileAds導入の注意点
GoogleMobileAdsを導入する場合、Info.plistにadmobかGoogle Ad ManagerのアプリIDの情報を記載しなければ、アプリがクラッシュします。- アプリIDの情報
 
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-################~##########</string>
<key>SKAdNetworkItems</key>
  <array>
    <dict>
      <key>SKAdNetworkIdentifier</key>
      <string>cstr6suwn9.skadnetwork</string>
    </dict>
  </array>
 2
3
4
5
6
7
8
9
GNAdGoogleMediationAdapterの追加
Cocoapodsで導入する
Podfileに以下を記述します。
pod 'Geniee-Google-Mediation-Adapter'
 手動で導入する
手動導入手順はこちら
GNAdGoogleMediationAdapter をダウンロードします。GNAdGoogleMediationAdapter.xcframework をドラッグアンドドロップでプロジェクトにコピーして追加してください。
ナビゲータエリアよりプロジェクトを選択し、"TARGET" => "General" を選択する。
"Linked Framework and Libraries" へ "GNAdGoogleMediationAdapter.xcframework" を追加する。
GNAdGoogleMediationAdapter 5.1.5以下のバージョンの場合、以下の手順を実行する。
"Embedded Binaries" へ "GNAdGoogleMediationAdapter.framework" を追加する。
共通対応
GNAdGoogleMediationAdapter 5.1.6以上のバージョンの場合、以下の手順は不要です。
GNAdGoogleMediationAdapter 5.1.5以下のバージョンの場合、以下の手順を実行する。
- ナビゲータエリアより"Pods/***.xcconfig" を選択する。
"OTHER_LDFLAGS" から -framework "GoogleMobileAds" を削除する。 - ナビゲータエリアよりプロジェクトを選択し、"TARGETS" -> "Build Settings" を選択する。
"Other Linker Flags" から "GoogleMobileAds" を削除する。 
Geniee SDK の追加
Geniee SDK のインストールは、下記スタートガイドから行ってください。
各アドネットワーク用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 | 
全画面インタースティシャル広告の実装
- AdManager
 
管理画面でメディエーション設定したUnitIDを指定することで、メディエーションを行い全画面広告を表示できます。
GoogleAdManagerの全画面実装方法については、以下のサイトを参考にしてください。
 GoogleAdManagerの全画面実装方法
- AdMob
 
管理画面でメディエーション設定したUnitIDを指定することで、メディエーションを行い全画面広告を表示できます。
AdMobの全画面実装方法については、以下のサイトを参考にしてください。
 AdMobの全画面実装方法
Google Ad Manager全画面インタースティシャル広告がNo fillとなる場合の対応
Google Ad Managerの全画面インタースティシャルがLoad失敗になった場合に、Geniee SDKを呼び出すことで、広告の空き枠を防ぐことができます。実装手順は以下の通りです。
GNAdSDK I/Fの使用準備
Geniee SDKの GNSFullscreenInterstitialAd をインポートします。
- ObjectiveC
ヘッダーファイルをimportし、Delegateを追加します。 
例:ViewController.h
- ObjectiveC
 
#import <GNAdSDK/GNSRequest.h>
#import <GNAdSDK/GNSFullscreenInterstitialAdDelegate.h>
@interface ViewController ()<GADInterstitialDelegate, GNSFullscreenInterstitialAdDelegate>
 2
3
- Swift
以下の内容のヘッダーファイルを追加します。 
#import <GNAdSDK/GNSRequest.h>
#import <GNAdSDK/GNSFullscreenInterstitialAdDelegate.h>
 2
ナビゲータエリアよりプロジェクトを選択し、"TARGET" -> "Build Settings" を選択する。
"Objective-C Bridging Header" へ 上記で作成したヘッダーファイルのパスを追加する。
Delegateメソッドを実装する
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 {
}
 2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- 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!) {
    }
}
 2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
全画面インタースティシャル広告のロード
Google Ad ManagerのLoadが失敗した場合に呼び出されるメソッドにGeniee SDK全画面インタースティシャルのloadメソッドを実装します。
ロードリクエストにZoneIDを指定します。
1つのインタースティシャルの再生完了後に別のインタースティシャルを見せる場合、再びロードリクエストを行う必要があります。
- ObjectiveC
 
GAMRequest *request = [GAMRequest request];
[GAMInterstitialAd loadWithAdManagerAdUnitID:@"YOUR_UNIT_ID" request:request completionHandler:^(GAMInterstitialAd *ad, NSError *error) {
    if (error) {
        GNSRequest *request = [GNSRequest request];
        [[GNSFullscreenInterstitialAd sharedInstance] loadRequest:request withZoneID:@"YOUR_SSP_ZONE_ID"];
        return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
}];
 2
3
4
5
6
7
8
9
10
- Swift
 
let request = GAMRequest()
GAMInterstitialAd.load(withAdManagerAdUnitID: "YOUR_UNIT_ID", request: request, completionHandler: { (ad, error) in
    if let error = error {
        let request = GNSRequest()
        GNSFullscreenInterstitialAd.sharedInstance().load(request, withZoneID: "YOUR_ZONE_ID")
        return
    }
    self.interstitial = ad
    self.interstitial.fullScreenContentDelegate = self
})
 2
3
4
5
6
7
8
9
10
全画面インタースティシャル広告表示
GoogleMobileAds SDK → Geniee SDKの順で、loadが完了しているかを確認し、showメソッドでインタースティシャルを表示します。
showは必ずGoogleMobileAdsのLoad実行後に実施するようにして下さい。
- ObjectiveC
 
if (self.interstitial) {
    [self.interstitial presentFromRootViewController:self];
} else if ([[GNSFullscreenInterstitialAd sharedInstance] canShow]) {
   [[GNSFullscreenInterstitialAd sharedInstance] show:self];
}
 2
3
4
5
- Swift
 
if let ad = interstitial {
    ad.present(fromRootViewController: self)
} else if GNSFullscreenInterstitialAd.sharedInstance().canShow() {
    GNSFullscreenInterstitialAd.sharedInstance().show(self)
}
 2
3
4
5