我想在我的应用中添加Admob,编译是正确的,但我无法在模拟器上看到横幅。 该应用适用于横向模式的iPad。 我将macbook的UUID添加到变量TEST_DEVICE_ID。
你能帮帮我吗?
由于
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
GAD_SIMULATOR_ID,
@"TEST_DEVICE_ID",
nil];
答案 0 :(得分:0)
首先,您实际上并没有将带有testDevices的请求传递给AdMob。要做到这一点,你会想写:
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
GAD_SIMULATOR_ID,
@"TEST_DEVICE_ID",
nil];
[bannerView_ loadRequest:request];
现在,当您实际发布时,您也希望能够获得实时广告。要了解更多信息,请实施GADBannerViewDelegate并记录您没有收到广告的原因:
- (void)adView:(GADBannerView *)view
didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"Failed to receive ad with error: %@", [error localizedFailureReason]);
}
请记住,您需要添加bannerView_.delegate = self;
来设置要触发此方法的委托。