Discussion Forums  >  Suggestions, Ideas, Wish List

Replies: 11    Views: 164

AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
01/07/15 10:22 AM (9 years ago)

Adding AdMob to IOS app

Has anyone successfully managed this?. I have tried following the admob example, but not having too much luck in my buzztouch project.
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
01/07/15 08:15 PM (9 years ago)
Talk to Adam.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/08/15 02:32 AM (9 years ago)
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
01/08/15 04:43 AM (9 years ago)
Cheers @sps, I've had a look, still a bit stuck. What I am doing is to follow the admob guidelines to install the SDK https://developers.google.com/mobile-ads-sdk/docs/admob/ios/quick-start#manually_using_the_sdk_download until the point where it talks about the first banner request. My app compiles so I assume I have added the SDK and linked the libraries in xcode OK. The problem I have is adding the code. I've added it to one of the BT plugins I am using, just as you posted //create adView? if([[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"includeAds" defaultValue:@"0"] isEqualToString:@"1"]){ bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height - GAD_SIZE_320x50.height -60, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)]; bannerView_.adUnitID = MY_BANNER_UNIT_ID; bannerView_.rootViewController = self; [self.view addSubview:bannerView_]; [bannerView_ loadRequest:[GADRequest request]]; } Because I am a non programmer, I am stumped by the red errors, basically all point to bannerView_ being undefined. It is probably something very basic.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/08/15 05:07 AM (9 years ago)
You have to define it in the .h file Import the Google Banner to the .h #import "GADBannerView.h" add this to the interface GADBannerView *bannerView_; - right under int downloadInProgress; In the .m Right under the @synthesize define your banner unit #define MY_BANNER_UNIT_ID @"ca-app-pub-7777777777/99999999" After that you shouldn't get any errors. Have you imported the sdk correctly. You should be fine after this if so.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
01/08/15 06:16 AM (9 years ago)
I think I added the sdk and all the extra frameworks OK; I followed the Admob guide there to the letter. With your (much appreciated) help I've added GADBannerView *bannerView_; and that eliminated all my errors, except one, which was to do with MY_BANNER_UNIT. I changed the line to read as follows (using a valid ID from one of my existing android apps): bannerView_.adUnitID = @"ca-app-pub-7777777777/99999999"; This removed the final error, but I don't see any ads in the simulator. Getting closer though!
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/08/15 06:46 AM (9 years ago)
Add the ad unit by defining it above like I do.. here is my code for the adview.. //create adView? if([[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"includeAds" defaultValue:@"0"] isEqualToString:@"1"]){ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height - GAD_SIZE_320x50.height -62, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)]; } else { bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height - GAD_SIZE_728x90.height -44, GAD_SIZE_728x90.width, GAD_SIZE_728x90.height)]; } bannerView_.adUnitID = MY_BANNER_UNIT_ID; bannerView_.rootViewController = self; [self.view addSubview:bannerView_]; [bannerView_ loadRequest:[GADRequest request]]; } }
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
01/08/15 07:29 AM (9 years ago)
THanks for that, made all the changes, I have no errors, but also no ads (yet). I then added NSLog(@"Admob - requesting a banner."); after bannerView_.adUnitID = MY_BANNER_UNIT_ID; In the log it showed 2015-01-08 14:10:23.412 helloworld[6140:1790997] Admob - requesting a banner. 2015-01-08 14:10:23.436 helloworld[6140:1790997] <Google> To get test ads on this device, call: request.testDevices = @[ @"c181fb407a94d7fe7687c18c7c5f8f8c" ]; I changed #define MY_BANNER_UNIT_ID @"c181fb407a94d7fe7687c18c7c5f8f8c" but it made no difference. Feels like I am close though.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/08/15 07:37 AM (9 years ago)
do you use tabs in this app?
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
01/08/15 07:52 AM (9 years ago)
No tabs. It is actually a test app that I wrote originally to learn how to use cr_menu_advanced and html pro that I thought I would adapt today, so it is freshly downloaded. It just has a 3 line menu for the home page, linking to a couple of custom html screens where I am trying to display the adverts.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
01/08/15 11:08 AM (9 years ago)
I started again completely from scratch. Whooohoo! just managed to make it work. Many thanks @mysps, I could not have done it without you. I've noticed that when clicking on the AdMob banner ad the user is navigated out of the app and into Safari. iAd pops up a window that leaves the user in the app, with a 'cancel' button top left that closes the window.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/08/15 11:20 AM (9 years ago)
Awesome!! Happy to help :) I think it depends on the type of ad most likely but I'm not 100% sure
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.