How to Add an AdMob Banners in your Application
Step-1: Before you add an admob banner you need to create an
account in site.
Then login by this account and click on the Monetize link. After then
click on “Add your app manually” and fill up like bellow image
Then "Select ad format and name ad unit[in second step]" like bellow After then
"View setup instructions[in third]" option click on the "Google abmob
SDK" and download for iOS
Step-2: In this step you need to unzip the downloaded file and add all files[without Add-ons folder] on your "Supporting files" folder in Xcode project.
Figure: Select all file for add Figure: Add all files on project
Step-3: In this step you need to add the following frameworks into your project in "Build Phases".
AdSupport , AudioToolbox , AVFoundation , CoreGraphics , CoreTelephony , MessageUI , StoreKit , SystemConfiguration .
Step-4: In this step you need to add -ObjC in the Other Linker Flags under "Build Settings" like bellow
Step-5: Now you need to add following codes in your project
In ViewController.h add bellow
#import <UIKit/UIKit.h>
#import "GADBannerView.h"
@interface ViewController : UIViewController {
GADBannerView *bannerView_;
}
@end
In ViewController.m add bellow code in the - (void)viewDidLoad function
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
bannerView_ =[[GADBannerView alloc]initWithFrame:CGRectMake(0, 20, 320, 50)];
bannerView_.adUnitID = @"ca-app-pub-Your adunitID"; // get from apps.admob.com site
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
}
[Then Run and enjoy your Ad banner. Last updated: 27-08-2014]