要在此设备上获得testing广告,请调用:request.testDevices = ;

当我在模拟器中testingAdmob时,会抛出错误

要在此设备上获得testing广告,请调用:request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID,nil];

我的代码

bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; bannerView_.adUnitID = @"8de66ecc3525495d"; bannerView_.rootViewController = self; [self.view addSubview:bannerView_]; GADRequest *request = [[GADRequest alloc] init]; request.testing = YES; [bannerView_ loadRequest:request]; 

指导我归档它。 提前致谢..

你必须添加你的testing设备。 随着斯威夫特,只需更换

 bannerView.load(GADRequest()) 

 let request: GADRequest = GADRequest() request.testDevices = [kGADSimulatorID] bannerView.load(request) 

如果你有一个iPhone,然后运行该应用程序,它会告诉你的ID:

要在此设备上获得testing广告,请调用:request.testDevices = @ [@“Here is the ID”];

添加了ID:

 let request: GADRequest = GADRequest() request.testDevices = ["PUT HERE THE ID", kGADSimulatorID] bannerView.load(request) 

干杯,保罗

终于修复了bug的朋友..

我犯了错误生成adUnitID 。 所以只有我不能得到广告的看法。

现在从xxxx站点获取一个adUnitID进行testing。 它的工作很好..

 adUnitID = @"a14dccd0fb24d45"; 

感谢所有支持者。

这适用于我:

 (GADRequest *)request { GADRequest *request = [GADRequest request]; // Make the request for a test ad. Put in an identifier for the simulator as well as any devices // you want to receive test ads. request.testDevices = @[ // TODO: Add your device/simulator test identifiers here. Your device identifier is printed to // the console when the app is launched. GAD_SIMULATOR_ID ]; return request;//thanks } 

我曾经这样做过:

 GADRequest *request = [GADRequest request]; // Make the request for a test ad. Put in an identifier for // the simulator as well as any devices you want to receive test ads. request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil]; [gAdBannerView loadRequest:request]; 

我在哪里定义

 // Constant for getting test ads on the simulator using the testDevices method. #define GAD_SIMULATOR_ID @"Simulator" 

我目前正在使用这个。 即使在模拟器中也适用于我。 我得到了错误,但这不是一个错误,我广泛search,发现它是更多的信息消息。

当testing模式设置为“否”时,重点是获得真实广告,当testing模式设置为“是”时,“成功,您现在准备好前往广告银河”消息。 因此,如果你在应用程序中有任何一个结果,应该没问题。 🙂

我的代码如下:

 GADBannerView *bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; bannerView_.adUnitID = GOOGLE_UNIT_ID; GADRequest *request = [GADRequest request]; bannerView_.delegate = self; bannerView_.rootViewController = self; // Make the request for a test ad. Put in an identifier for // the simulator as well as any devices you want to receive test ads. request.testDevices = [NSArray arrayWithObjects: GAD_SIMULATOR_ID, nil]; // Initiate a generic request to load it with an ad. [bannerView_ loadRequest:request]; 

我没有把testing设置为YES。 我的Google AdMobs SDK版本是6.5.1

既然你提到你需要生产帮助,那么不应该把它设置为testing模式,所以你应该在没有testing模式的情况下运行它。

考虑在模拟器上运行还是在真实设备上运行并不重要,都应该在两个设备上运行。 我在代码中将代理设置为self,因此如果执行相同的操作,则可以使用以下方法:

 - (void) adView: (GADBannerView*) view didFailToReceiveAdWithError: (GADRequestError*) error - (void) adViewDidReceiveAd: (GADBannerView*) view 

这些可以帮助您检查是否已经收到广告,即使在模拟器中运行。

希望这可以帮助! 🙂