AdMobの実装(iOS)
AdMobは
No Ad to show.
のエラーがでてさえいれば、実装は間違ってない。
管理ツールで、
自社広告を表示回数指定して、テストモードオンにして、
他の広告枠でテストして、また元の広告枠に戻ったら表示された(なぜか自社広告は表示されない。)
ので、根本的なところは、AdMob側のバグ(仕様)としか思えない。
コードは、公式ドキュメントまんまでOK.
テストモードは、
rq.testDevices
これを忘れないこと。
// Create a view of the standard size at the bottom of the screen. bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height-GAD_SIZE_320x50.height, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)]; // Specify the ad's "unit identifier." This is your AdMob Publisher ID. bannerView_.adUnitID = @"a14e8887aa497ff"; bannerView_.delegate = self; // bannerView_.backgroundColor = [UIColor blackColor]; // Let the runtime know which UIViewController to restore after taking // the user wherever the ad goes and add it to the view hierarchy. bannerView_.rootViewController = self; GADRequest *rq = [GADRequest request]; rq.testDevices = [NSArray arrayWithObjects: GAD_SIMULATOR_ID,[[UIDevice currentDevice] uniqueIdentifier], nil]; [bannerView_ loadRequest:rq];
エラーは下記でとる。bannerView_.delegate = self;がもちろん必要。
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error{ NSLog(@"error %@",error); }