How to integrate GoogleAdmob in cocos2d-x (Portrait mode)

In order to integrate the google admob to your existing project,firstly copy the following banner view classes and GoogleAdMobAdsSDK in proj.ios folder of your project

Banner View Classes
GoogleAdMobAdsSDK

After copying,the folder will look like this:

Screen Shot 2014-06-25 at 10.49.42 AM

Now your project folder is ready for the integration,go to your Xcode project,open it,add these classes of banner view to your project directly by right click on project and click on “Add Files to project_name” option

For GoogleAdMobAdsSDK,add this in Frameworks folder and also make sure the following frameworks should be in your project,if not,then must add through Link Binary With Libraries option in Build Phases:

Screen Shot 2014-06-25 at 11.59.51 AM

After making all above changes,the project in Xcode look like this:

Screen Shot 2014-06-25 at 11.51.52 AM

Now make changes in AppController.h(inside the ios folder) class so that it will look like this:

Screen Shot 2014-06-25 at 11.06.46 AM

Go to AppController.mm,and add the following lines after “@implementation AppController”

and it will shown as:

Screen Shot 2014-06-25 at 11.07.06 AM

Now go to function – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions inside the same class and search for the following lines:

Delete these above lines and add the following bvc banner view code after the line “viewController.view = __glView;”

and it will look like this:

Screen Shot 2014-06-25 at 11.07.57 AM

Now,2 more imp. things left,firstly make following changes in BannerViewController.m file:

Next go to function named as -(void)loadReqForAdmob:(BannerViewController*)ctrll inside the same class and change the UDID numbers as per your devices:

Now run your project,if it shows some error of weak property of BannerViewController.m,then add “-fobjc-arc” in front of BannerViewController.m in Compile Sources inside the Build Phases of project TARGETS:shown as below

Screen Shot 2014-06-25 at 12.16.13 PM

1,302 total views, 2 views today

Share this OnShare on FacebookTweet about this on TwitterShare on LinkedInShare on Google+

Leave a Reply