使用 SDK 7.1.0 版测试 AdMob 广告出现在 iOS 个模拟器上
Test AdMob ads appear on iOS emulator with Version 7.1.0 of SDK
我最近更新了我的应用程序以使用 7.1.0 版的 GoogleMobileAdsSDK。更新后,广告已从实时广告变为测试广告,尽管我没有对用于创建广告的代码进行任何更改。这些广告是否也会在下载我的应用程序的设备上测试广告,或者这在 SDK 7.1.0 版本中是否正常?
这是我用来制作横幅的代码:
+ (void)createBanner:(UIViewController *)sender {
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{
bannerHeight = 50;
}
else
{
bannerHeight = 90;
}
GADRequest *request = [GADRequest request];
// request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView.adUnitID = @"ca-app-pub-1852329945819279/3391317943";
bannerView.rootViewController = (id)self;
bannerView.delegate = (id<GADBannerViewDelegate>)self;
senderView = sender.view;
bannerRect = [bannerView bounds];
bannerView.frame = CGRectMake(0, 0, senderView.frame.size.width, bannerHeight);
[bannerView loadRequest:request];
containerView = [[UIView alloc] initWithFrame:senderView.frame];
bannerContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, senderView.frame.size.height, senderView.frame.size.width, bannerHeight)];
for (id object in sender.view.subviews) {
[object removeFromSuperview];
[containerView addSubview:object];
}
[senderView addSubview:containerView];
[senderView addSubview:bannerContainerView];
}
+ (void)adViewDidReceiveAd:(GADBannerView *)view
{
[UIView animateWithDuration:0.5 animations:^{
containerView.frame = CGRectMake(0, 0, senderView.frame.size.width, senderView.frame.size.height - bannerHeight);
bannerContainerView.frame = CGRectMake(0, senderView.frame.size.height - bannerHeight, senderView.frame.size.width, bannerHeight);
[bannerContainerView addSubview:bannerView];
}];
}
自从把SDK升级到7.1.0后,这段代码我一直没改,却出现了测试广告,所以我很疑惑。所有帮助表示赞赏。谢谢。
https://developers.google.com/mobile-ads-sdk/docs/admob/ios/targeting#test_ads
根据文档:Note: Starting in SDK version 7.0.0, simulators will automatically show test ads.
我最近更新了我的应用程序以使用 7.1.0 版的 GoogleMobileAdsSDK。更新后,广告已从实时广告变为测试广告,尽管我没有对用于创建广告的代码进行任何更改。这些广告是否也会在下载我的应用程序的设备上测试广告,或者这在 SDK 7.1.0 版本中是否正常?
这是我用来制作横幅的代码:
+ (void)createBanner:(UIViewController *)sender {
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{
bannerHeight = 50;
}
else
{
bannerHeight = 90;
}
GADRequest *request = [GADRequest request];
// request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView.adUnitID = @"ca-app-pub-1852329945819279/3391317943";
bannerView.rootViewController = (id)self;
bannerView.delegate = (id<GADBannerViewDelegate>)self;
senderView = sender.view;
bannerRect = [bannerView bounds];
bannerView.frame = CGRectMake(0, 0, senderView.frame.size.width, bannerHeight);
[bannerView loadRequest:request];
containerView = [[UIView alloc] initWithFrame:senderView.frame];
bannerContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, senderView.frame.size.height, senderView.frame.size.width, bannerHeight)];
for (id object in sender.view.subviews) {
[object removeFromSuperview];
[containerView addSubview:object];
}
[senderView addSubview:containerView];
[senderView addSubview:bannerContainerView];
}
+ (void)adViewDidReceiveAd:(GADBannerView *)view
{
[UIView animateWithDuration:0.5 animations:^{
containerView.frame = CGRectMake(0, 0, senderView.frame.size.width, senderView.frame.size.height - bannerHeight);
bannerContainerView.frame = CGRectMake(0, senderView.frame.size.height - bannerHeight, senderView.frame.size.width, bannerHeight);
[bannerContainerView addSubview:bannerView];
}];
}
自从把SDK升级到7.1.0后,这段代码我一直没改,却出现了测试广告,所以我很疑惑。所有帮助表示赞赏。谢谢。
https://developers.google.com/mobile-ads-sdk/docs/admob/ios/targeting#test_ads
根据文档:Note: Starting in SDK version 7.0.0, simulators will automatically show test ads.