2回目以降も表示するようにするためには、インタースティシャル広告が閉じられたときに、新たな広告リクエストをしなければならない。
ViewController.h
#import "GADInterstitial.h"
@interface ViewController : UIViewController <GADInterstitialDelegate>
{
GADInterstitial *interstitial_; // AdMobインタースティシャル広告
}
ViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
// AdMobインタースティシャルのロード
[self interstitialLoad];
}
- (void)interstitialLoad {
// AdMobインタースティシャルのロード
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID = @"YOUR-PUBLISHER-ID";
interstitial_.delegate = self;
[interstitial_ loadRequest:[GADRequest request]];
}
- (void)interstitialDidDismissScreen:(GADInterstitial *)interstitial {
[self interstitialLoad];
}
- (void)hoge {
// AdMobインタースティシャル広告の表示
if ([interstitial_ isReady]) {
[interstitial_ presentFromRootViewController:self];
}
}
解説
1. viewDidLoad にて、初回のインタースティシャル広告のリクエストを行う。
2. hogeメソッドでインタースティシャル広告を表示する。
3. インタースティシャル広告が閉じられると、GADInterstitialDelegateメソッドの interstitialDidDismissScreen が呼ばれる。ここで、次に表示するインタースティシャル広告のリクエストを行う。
参考記事:
https://developers.google.com/mobile-ads-sdk/docs/admob/ios/interstitial#only_load_gadinterstitial_once
https://developers.google.com/mobile-ads-sdk/docs/admob/advanced?hl=ja#ios
http://stackoverflow.com/questions/24350523/admob-interstitial-shown-only-once-on-ios