{"id":2978,"date":"2012-01-10T13:35:01","date_gmt":"2012-01-10T08:35:01","guid":{"rendered":"http:\/\/aasims.wordpress.com\/?p=2978"},"modified":"2025-04-27T19:31:35","modified_gmt":"2025-04-27T19:31:35","slug":"admob-integration-in-ios-application","status":"publish","type":"post","link":"https:\/\/aasimnaseem.com\/blog\/admob-integration-in-ios-application\/","title":{"rendered":"Integrate AdMob in iOS Application;"},"content":{"rendered":"<p>Hello Everyone;<br \/>\nHope winters are going good around you;<\/p>\n<p>Today&#8217;s menu is again simple and short; We&#8217;ll learn how to integrate\u00a0AdMob in an iOS application. I will show you the easiest way to integrate AdMob in the application. So lets start;<\/p>\n<p><!--more--><strong>Step 1:<\/strong>\u00a0Open the Xcode, Create a new project using View base application. Give the application \u201cAdmobiPhone\u201d.<\/p>\n<p><strong>Step 2:<\/strong>\u00a0Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.<\/p>\n<p><strong>Step 3: <\/strong>Expand\u00a0classes and notice Interface Builder created the AdmobiPhoneViewController class for you and generated a separate nib, <strong>AdmobiPhoneViewController.xib<\/strong> for the \u201cAdmobiPhone\u201d.<\/p>\n<p><strong>Step 4:<\/strong>\u00a0First go to www.admob.com site, we need to register in this site for AdMob. After login, goto Sites &amp;Apps \u2013&gt; Add site\/App \u2013&gt; Select a site or app type \u2013&gt; Select iPhone App (See figure 1)<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" title=\"1-15\" src=\"http:\/\/www.edumobile.org\/iphone\/wp-content\/uploads\/2011\/05\/1-15-300x254.jpg\" alt=\"\" \/><\/p>\n<p>Now you can download the AbMob SDK, it is required for publishing Ads and drag drop into the Xcode project.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" title=\"3-3\" src=\"http:\/\/www.edumobile.org\/iphone\/wp-content\/uploads\/2011\/05\/3-3-300x222.jpg\" alt=\"\" \/><\/p>\n<p><strong>Step 5:<\/strong>\u00a0We need to add framework in project, so select the framework -&gt; add New Framework -&gt; Select AudioTollbox.framework, MediaPlayer.framework,MessageUI.framework and SystemConfiguration.framework add in the Framework folder.<\/p>\n<p><strong>Step 6:<\/strong>\u00a0We need to add one background image in the project.<\/p>\n<p><strong>Step 7:\u00a0<\/strong>Open the AdmobiPhoneViewController.h file, in this file we need to import GADBannerView.h file and create a instance of GADBannerView class. So make the following changes:<\/p>\n<p>[sourcecode language=&#8221;objc&#8221;]<\/p>\n<p>#import<br \/>\n#import &amp;quot;GADBannerView.h&amp;quot;<\/p>\n<p>@interface\u00a0AdmobiPhoneViewController\u00a0:\u00a0UIViewController\u00a0{<br \/>\nGADBannerView\u00a0*AbMob;<br \/>\n}<br \/>\n@end<\/p>\n<p>[\/sourcecode]<\/p>\n<p><strong>Step 8:<\/strong>\u00a0\u00a0Now open the AdmobiPhoneViewController.m file and make the following changes in the file.<\/p>\n<p>[sourcecode language=&#8221;objc&#8221;]&amp;lt;\/pre&amp;gt;<br \/>\n&amp;lt;div&amp;gt;#import &amp;quot;AdmobiPhoneViewController.h&amp;quot;<br \/>\n#define AdMob_ID @&amp;quot;a14dccd0fb24d45&amp;quot; \/\/ You can get this id from www.admob.com. This is Publisher ID<\/p>\n<p>@implementation\u00a0AdmobiPhoneViewController<\/p>\n<p>&#8211;\u00a0(void)dealloc<br \/>\n{<br \/>\nAbMob.delegate\u00a0=\u00a0nil;<br \/>\n[AbMob release];<br \/>\n[super dealloc];<br \/>\n}<\/p>\n<p>&#8211;\u00a0(void)didReceiveMemoryWarning<br \/>\n{<br \/>\n\/\/ Releases the view if it doesn\u2019t have a superview.<br \/>\n[super didReceiveMemoryWarning];<\/p>\n<p>\/\/ Release any cached data, images, etc that aren\u2019t in use.<br \/>\n}<\/p>\n<p>#pragma mark \u2013 View lifecycle<\/p>\n<p>\/\/ Implement viewDidLoad to do additional setup after loading the view, typically from a nib.<br \/>\n&#8211;\u00a0(void)viewDidLoad<br \/>\n{<br \/>\n[super viewDidLoad];<br \/>\nAbMob\u00a0=\u00a0[[GADBannerView alloc]<br \/>\ninitWithFrame:CGRectMake(0.0,<br \/>\nself.view.frame.size.height\u00a0&#8211;<br \/>\nGAD_SIZE_320\u00d770.height,<br \/>\nGAD_SIZE_320\u00d770.width,<br \/>\nGAD_SIZE_320\u00d770.height)];<\/p>\n<p>AbMob.adUnitID\u00a0=\u00a0AdMob_ID;<br \/>\nAbMob.rootViewController\u00a0=\u00a0self;<br \/>\n[self.view addSubview:AbMob];<\/p>\n<p>GADRequest\u00a0*r\u00a0=\u00a0[[GADRequest alloc]\u00a0init];<br \/>\nr.testing\u00a0=\u00a0YES;<br \/>\n[AbMob loadRequest:r];<\/p>\n<p>}<\/p>\n<p>&#8211;\u00a0(void)viewDidUnload<br \/>\n{<br \/>\n[super viewDidUnload];<br \/>\n\/\/ Release any retained subviews of the main view.<br \/>\n\/\/ e.g. self.myOutlet = nil;<br \/>\n}<\/p>\n<p>&#8211;\u00a0(BOOL)shouldAutorotateToInterfaceOrientation:<br \/>\n(UIInterfaceOrientation)interfaceOrientation<br \/>\n{<br \/>\n\/\/ Return YES for supported orientations<br \/>\nreturn\u00a0(interfaceOrientation\u00a0==\u00a0UIInterfaceOrientationPortrait);<br \/>\n}<\/p>\n<p>@end&amp;lt;\/div&amp;gt;<br \/>\n&amp;lt;pre&amp;gt;<br \/>\n[\/sourcecode]<\/p>\n<p><strong>Step 9:<\/strong>\u00a0Now compile and run the application on the device.<\/p>\n<div><em>from: eduMobile;<\/em><\/div>\n<div><\/div>\n<p><img decoding=\"async\" src=\"http:\/\/s03.flagcounter.com\/count\/bXD\/bg_FFFFFF\/txt_000000\/border_FFFFFF\/columns_6\/maxflags_248\/viewers_0\/labels_1\/pageviews_1\/flags_0\/\" alt=\"free counters\" border=\"0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Everyone; Hope winters are going good around you; Today&#8217;s menu is again simple and short; We&#8217;ll learn how to integrate\u00a0AdMob in an iOS application. I will show you the easiest way to integrate AdMob in the application. So lets start;<\/p>\n","protected":false},"author":1,"featured_media":5174,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[94,106,398,437,506,538,1117],"class_list":["post-2978","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ios","tag-abmob-adunitid","tag-admob","tag-gadbannerview","tag-google-admob","tag-how-to-integrate-admob-in-iphone","tag-interface-builder","tag-xcode"],"_links":{"self":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/2978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/comments?post=2978"}],"version-history":[{"count":3,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/2978\/revisions"}],"predecessor-version":[{"id":5175,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/2978\/revisions\/5175"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/media\/5174"}],"wp:attachment":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/media?parent=2978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/categories?post=2978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/tags?post=2978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}