我有我的一個廣告這個問題對於IOS遊戲AdMob聯播bannerView請求錯誤:沒有廣告顯示
這裏是我的代碼,奇怪的是,如果我添加了設備上的要求。 testDevices列表顯示演示橫幅,如果我從testDevices中移除,它不會顯示真正的橫幅,但是如果我在XCODE上更改我的bundleIdentifier,它會顯示一個真正的橫幅,所以我相信它與我的admob帳戶有關,是否有人有類似的東西?
它總是得到這個錯誤:
的AdView didFailToReceiveAdWithError ---------------------------:錯誤域=融爲一體。 google.ads代碼= 1「請求錯誤:無廣告顯示。」的UserInfo = {NSLocalizedDescription =請求錯誤:沒有廣告顯示,NSLocalizedFailureReason =請求錯誤:沒有廣告顯示}
在我AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Use Firebase library to configure APIs
[FIRApp configure];
[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:YES];
// Initialize Google Mobile Ads SDK
[GADMobileAds configureWithApplicationID:@"ca-app-pub-xx~xx"];
/* other stuff here... */
}
我rootViewController.m
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
bannerViewAdded = NO;
interstitialViewAdded = NO;
[self addBanner];
// ..... more stuff here;
}
- (void)addBanner{
NSLog(@"CALL ADD BANNER ROOTVIEWCONTROLLER");
if(!bannerViewAdded && ![MKStoreManager isFeaturePurchased:kFeatureAId]){
NSLog(@"ADD BANNER ROOTVIEWCONTROLLER");
CGSize size = [[CCDirector sharedDirector] winSize];
// Create adMob ad View (note the use of various macros to detect device)
if (IS_IPAD || IS_IPADHD) {
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeLeaderboard];
bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
}
else if (IS_IPHONE6) {
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
}
else if (IS_IPHONE6P) {
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
}
else {
// boring old iPhones and iPod touches
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
}
//[bannerView setBackgroundColor:[UIColor blueColor]];
// Need to set this to no since we're creating this custom view.
//bannerView.translatesAutoresizingMaskIntoConstraints = NO;
// Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID
// before compiling.
// Replace this ad unit ID with your own ad unit ID.
bannerView.adUnitID = @"ca-app-pub-xx/xx";
bannerView.rootViewController = self;
bannerView.delegate = self;
[self.view addSubview:bannerView];
GADRequest *request = [GADRequest request];
//request.testDevices = @[ kGADSimulatorID ];
//request.testDevices = @[ @"xx", @"xx" , kGADSimulatorID ];
[bannerView loadRequest:request];
bannerViewAdded = YES;
}
}
- (void)removeBanner {
//admob
if(bannerViewAdded){
bannerViewAdded = NO;
[bannerView removeFromSuperview];
[bannerView release];
bannerView = nil;
}
//No AdMOB
if(localBannerAdded){
localBannerAdded = NO;
[localBannerButton removeFromSuperview];
[localBannerButton release];
localBannerButton = nil;
}
}
- (void)addInterstitial{
if(!interstitialViewAdded && ![MKStoreManager isFeaturePurchased:kFeatureAId]){
NSLog(@"INIT INTERSTITIAL ROOTVIEWCONTROLLER");
interstitialView = [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-xx/xx"];
GADRequest *request = [GADRequest request];
// Requests test ads on devices you specify. Your test device ID is printed to the console when
// an ad request is made. GADBannerView automatically returns test ads when running on a
// simulator.
//request.testDevices = @[ kGADSimulatorID, @"xxx", @"xxx" ];
[interstitialView loadRequest:request];
[interstitialView setDelegate:self];
}
}
- (void)adView:(GADBannerView *)gadBannerView didFailToReceiveAdWithError:(GADRequestError *)error{
NSLog(@"AdView didFailToReceiveAdWithError --------------------------- : %@", error);
[self removeBanner];
if(!localBannerAdded){
CGSize size = [[CCDirector sharedDirector] winSize];
localBannerButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
localBannerButton.frame = CGRectMake(0.0, 0.0, 320.0, 50.0);
[localBannerButton setTitle:@"DOWNLOAD MORE FREE GAMES" forState:UIControlStateNormal];
localBannerButton.backgroundColor = [UIColor whiteColor];//[UIColor clearColor];
[localBannerButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
[self.view addSubview:localBannerButton];
[localBannerButton setCenter:CGPointMake(self.view.center.x,(size.height-CGRectGetHeight(localBannerButton.frame)/2)-2)];
// Add Target-Action Pair
[localBannerButton addTarget:self action:@selector(openAppStore:) forControlEvents:UIControlEventTouchUpInside];
localBannerAdded = YES;
}
}
我的旗幟已經從遊戲試玩區1米像素的距離,因此刪除的旗幟玩遊戲畫面,並要求新的評估,爲我確定。令人遺憾的是,花了將近3個月的時間才從Admob那裏得到問題的答案,我從來沒有收到過一封電子郵件,或者是來自admob的任何其他聯繫人。在蘋果批准我的遊戲的新版本之後,修復速度很快,在12小時內我的旗幟又回來了。 –