简体   繁体   中英

Xcode - Admob banner setting with targeting and test devices

I am working on my iOS app and trying to place a banner on the bottom of the page.

First of all, I set a BOOL (BannerAd) which is initially "NO" and set to "YES" when user hits the "Submit" button. By doing this tried to avoid requesting ads eveytime the user hit "Submit". This seems to work but world be nice if you can comment on it.

My interface has a "Datepicker" where the user selects his/her Birthday. I wanted to use this information for ad targeting. Also I know my application will be used in "Germany" so I set the location manually to "Germany" since my app doesn't request location information from user. And finally I am trying to test my app on my device where I set my test device UDID in "testDevices"

My problem is, I think my requests don't work. When I enter my own "adUnitId", I get paid ads on my device (which may cause a problem). Also when I tried to change the location, for example to "France", I still get local ads. I guess my location is not working and AdMob is using the network to determine the location. Which makes me think my "Birthday" information isn't working, too.

Below is the code I use and I don't know which part is wrong. I did researched and did everything according to the guides. I am not experienced and hoped that you guys can help me out!

Appreciated!

    // Show Banner Ad
    if (BannerAd == NO)
    {
        self.bannerView.adUnitID = @"ca-app-pub-3940256099942544/2934735716"; // TEST ID
        self.bannerView.rootViewController = self;

        NSDate *birthday =[datepick date];

        GADRequest *request = [GADRequest request];
        [request setBirthday: birthday];
        [request setLocationWithDescription:@"Germany"];
        request.testDevices = @[ @"b23cbd41317324cd9afd14dc848f2f0e" // TEST DEVICE
                                 ];

        [self.bannerView loadRequest:[GADRequest request]];

        BannerAd = YES;}

I can't understand your question(s) so good. Sorry. If you want to put your adMob banner on the bottom of the screen, just use:

bannerView = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0,self.view.frame.size.height - 50, self.view.frame.size.width, CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height)];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM