-(void)resetAdView:(UIViewController *)rootViewController {
currentDelegate_ = rootViewController;
if (ADloads) {
[rootViewController.view addSubview:adBanner_];
adBanner_.delegate = self;
adBanner_.rootViewController = rootViewController;
adBanner_.adUnitID = @"Unit-ID";
GADRequest *request = [GADRequest request];
[adBanner_ loadRequest:request];
ADloads = YES;
request.testDevices= @[ GAD_SIMULATOR_ID ];
} else {
adBanner_.delegate = self;
adBanner_.rootViewController = rootViewController;
adBanner_.adUnitID = @"Unit-ID";
GADRequest *request = [GADRequest request];
[adBanner_ loadRequest:request];
[rootViewController.view addSubview:adBanner_];
ADloads = YES;
request.testDevices= @[ GAD_SIMULATOR_ID ];
}
}
无法理解为什么 AdMob 只发送真实广告而不发送我请求的测试广告。它只发送真实广告的代码有什么问题?
最佳答案
[adBanner_ loadRequest:request]; // send request
[rootViewController.view addSubview:adBanner_];
ADloads = YES;
request.testDevices= @[ GAD_SIMULATOR_ID ] // modify request to add test device
将模拟器添加为测试设备的行位于发送请求的行之后。此时请求已经发送到服务器。太晚了。
尝试重新排序您的语句,看看会发生什么。
关于ios - AdMob 只发送真实广告,而不发送测试广告,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28225444/