Bal*_*i G 13 objective-c admob ios
当我在模拟器中测试Admob时,它会抛出错误
要在此设备上获取测试广告,请调用: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];
Run Code Online (Sandbox Code Playgroud)
引导我归档它.提前致谢..
Spi*_*pau 25
你必须添加你的测试设备.使用Swift,只需更换即可
bannerView.load(GADRequest())
Run Code Online (Sandbox Code Playgroud)
同
let request: GADRequest = GADRequest()
request.testDevices = [kGADSimulatorID]
bannerView.load(request)
Run Code Online (Sandbox Code Playgroud)
如果您有iPhone,那么也运行应用程序,它会告诉您ID:
要在此设备上投放测试广告,请致电:request.testDevices = @ [@"此处为ID"];
ID添加:
let request: GADRequest = GADRequest()
request.testDevices = ["PUT HERE THE ID", kGADSimulatorID]
bannerView.load(request)
Run Code Online (Sandbox Code Playgroud)
干杯,保罗
自最新更新以来request.testDevices已替换为:
GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers
Run Code Online (Sandbox Code Playgroud)
我已经让它与这个一起工作:
GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = [(kGADSimulatorID as! String)]
Run Code Online (Sandbox Code Playgroud)
[编辑]
在我的应用程序委托中,我使用以下代码:
GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers
Run Code Online (Sandbox Code Playgroud)
适用于 Swift 5、iOS 13 和 Google-Mobile-Ads-SDK (7.58.0)
最后修复了bug的朋友..
我错误地生成了adUnitID.所以只有我无法获得广告视图.
现在从xxxx网站获取一个adUnitID进行测试.它的工作正常..
adUnitID = @"a14dccd0fb24d45";
Run Code Online (Sandbox Code Playgroud)
感谢所有支持者.