Murali Patteboyina
Murali Patteboyina

Reputation: 387

Admob test devices not showing simulator udid

I am implementing Admob on iOS app.

I just downloaded Admob sample code and when I tried to run it on simulator, my console is saying "To get test ads on this device, call: request.testDevices = NSArray arrayWithObjects:@"GAD_SIMULATOR_ID", nil];".

So, I added my mac udid and a testing device udid to an array and set that to request. But, still, app is showing the default banner instead of ads from my admob account. Also console is saying the same above message. Have anyone had any idea what am I missing here? Here is the code.

self.adBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
                                              origin:origin];
self.adBanner.adUnitID = kSampleAdUnitID;
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[self.view addSubview:self.adBanner];
self.adBanner.center = CGPointMake(self.view.center.x, self.adBanner.center.y);
GADRequest *request = [GADRequest request];
request.testing = YES;
request.testDevices = [NSArray arrayWithObjects: @"XXXX-XXXX-XXXX-XXXX-XXXXXXXX",
                                            @"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                                            nil];
[self.adBanner loadRequest:request];

BTW, I replaced the above kSampleAdUnitID with my Admob publisher ID and XXX with my mac id and device id.

Upvotes: 6

Views: 4917

Answers (3)

Mike
Mike

Reputation: 671

The Devce Id you need is the MD5 hash of the advertising identifier for your phone. I downloaded an app called 'The Identifiers' link here which gives you all the information you need.

Add the MD5 hash of the advertising identifier to the testDevices array in the createView method and you will then see adds in your app.

var ad1 = Admob.createView({
             height: 50,
             top: 0,
             debugEnabled: true, // If enabled, a dummy value for `adUnitId` will be used to test
             adType: Admob.AD_TYPE_BANNER,
             adUnitId: 'ca-app-pub-000000xxxxxxxxxx/8204200000', // You can get your own at http: //www.admob.com/
             adBackgroundColor: 'black',
             testDevices: [Admob.SIMULATOR_ID,'xxxc8xx0xxxccxxb4a12cxxxxxxxxxxx'], // You can get your device's id by looking in the console log
              dateOfBirth: new Date(1985, 10, 1, 12, 1, 1),
              gender: Admob.GENDER_MALE, // GENDER_MALE or GENDER_FEMALE default: undefined
             contentURL: 'https://admob.com', // URL string for a webpage whose content matches the app content.
             requestAgent: 'Titanium Mobile App', // String that identifies the ad request's origin.
    extras: {
       'version': 1.0,
       'name': 'Eyespy'
    }, // Object of additional infos
    tagForChildDirectedTreatment: false, // http:///business.ftc.gov/privacy-and-security/childrens-privacy for more infos
     keywords: ['keyword1', 'keyword2']
     });

    $.adview.add(ad1);

Upvotes: 1

klaevv
klaevv

Reputation: 467

Enable test ads

On your iDevice, go to Settings > Privacy > Advertising and disable the 'Limit Ad Tracking' option. Then when you run your app on hardware, check Xcode's console: there you will see the ID, which you can add to the testDevices array.

Upvotes: 8

Hai Hw
Hai Hw

Reputation: 1447

Actually, you don't need to add testDevices to be able to received ad
I also don't received ad, but when I remove my deviceId in testDevices, it works
Btw, if you want to add simulator ID just use @"GAD_SIMULATOR_ID", this is the default ID for the simulator, you only need real ID for real device.

Upvotes: 0

Related Questions