Ad Mob code in ios

 
    bannerView = [[GADBannerView alloc]
                  initWithFrame:CGRectMake(0, 335, 320, 35)];

                                  (or)

    AbMob = [[GADBannerView alloc]
      initWithFrame:CGRectMake(0.0,
                      self.view.frame.size.height – GAD_SIZE_300x250.height,GAD_SIZE_320x50.width,GAD_SIZE_320x50.height)];
    
    
    bannerView.adUnitID = @”your admob id”;
    bannerView.rootViewController = self;
    [self.view addSubview:bannerView];
    
    
    GADRequest *r = [[GADRequest alloc] init];

//keep testing =Yes if the ad is in testing phase and while uplaoding to appstore remove this line
    r.testing = YES;
    [bannerView loadRequest:r];
    

The frameworks need to be included for admobs are

  • StoreKit
  • AudioToolbox
  • MessageUI
  • SystemConfiguration
  • CoreGraphics
  • AdSupport

and do not forget if you are using the admob version> 6.1 add -ObjC to Otherlinker flags in build settings

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s