Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

While i test Admob in simulator, it throws below error

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

My Code

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

Guide me to archive it. Thanks in Advance..

like image 297
Balaji G Avatar asked Oct 22 '13 20:10

Balaji G


3 Answers

You have to add your test devices. With Swift, just replace

bannerView.load(GADRequest())

with

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

If you have an iPhone, then run the application too and it will tell you the ID.

To get test ads on this device, call: request.testDevices = @[@"HERE IS THE ID"];

ID added:

let request: GADRequest = GADRequest()
request.testDevices = ["PUT HERE THE ID", kGADSimulatorID]
bannerView.load(request)
like image 115
Paul Spiesberger Avatar answered Nov 16 '22 14:11

Paul Spiesberger


At finally fix the bug friends..

I made mistake to generate adUnitID. So only i cannot get ad view.

Now get one adUnitID from xxxx site for testing. And its working fine..

adUnitID = @"a14dccd0fb24d45";

Thanks for All Supporters.

like image 27
Balaji G Avatar answered Nov 16 '22 12:11

Balaji G


Since the newest update the request.testDevices has been replaced with:

GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers

I have gotten it to work with this:

GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = [(kGADSimulatorID as! String)]

[EDIT]

In my app delegate I am using this code:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
    // use this for production 
    GADMobileAds.sharedInstance().start(completionHandler: nil)
    // use this for testing 
    GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers = [ kGADSimulatorID ]
        
    return true
}

This is for Swift 5, iOS 13 and Google-Mobile-Ads-SDK (7.58.0)

like image 4
Tad Scritchfield Avatar answered Nov 16 '22 14:11

Tad Scritchfield