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..
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)
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With