To get test ads on this device, call: request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];

前端 未结 6 1253
走了就别回头了
走了就别回头了 2021-02-07 13:16

While i test Admob in simulator, it throws below error

To get test ads on this device, call: request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATO

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-07 13:57

    I am currently using this. Works for me even in the simulator. I got the error, but it isn't an error, I searched extensively and found out that it is more of an informative message.

    The main point will be to get the real ad showing when the testing mode is set to NO, and a "Success, you are now ready to travel the ad galaxy" message when the testing mode is set to YES. Therefore, if you have either of the results in the app, it should be fine. :)

    My code is as follows:

    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];
    

    I did not set the testing as YES. My Google AdMobs SDK version is 6.5.1

    Since you were mentioning that you need help for production, it should not be set to testing mode anyway, so you should probably run it without test mode.

    Looking at the question of whether running on simulator or real device does not matter, it should run on both the devices. I set the delegate to self in my codes, and therefore if you do the same, you can use the methods:

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

    These can help you in checking if you have received the ads at all, even when running in simulator.

    Hope this helps! :)

提交回复
热议问题