add Admob with Cocos2d-x on iOS

add Admob with Cocos2d-x on iOS

(2013-02-27 14:12:00)

转载▼

标签:

c=blog&q=it&by=tag" target="_blank" style="text-decoration:none; color:rgb(62,115,160); white-space:nowrap">it

 

1. download admob, setup your account

2. add admob to xcode project. You need:

- add libGoogleAdmobAds.a to bundle libraries

- create a group and add admob header file

3.  in AppController.h, add member:

@interface AppController : NSObject <</span>UIAccelerometerDelegate, UIAlertViewDelegate,UITextFieldDelegate,UIApplicationDelegate, GADBannerViewDelegate>
{

UIWindow *window;

RootViewController    *viewController;

GADBannerView* bannerView_;

}

4. in AppController.mm

// setup admob

// Create a view of the standard size at the bottom of the screen.

// Available AdSize constants are explained in GADAdSize.h.

bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];

bannerView_.delegate = self;

// Specify the ad‘s "unit identifier." This is your AdMob Publisher ID.

bannerView_.adUnitID = @"YOUR_ID";

// Let the runtime know which UIViewController to restore after taking

// the user wherever the ad goes and add it to the view hierarchy.

bannerView_.rootViewController = viewController;

[viewController.view addSubview:bannerView_];

// Initiate a generic request to load it with an ad.

GADRequest* adRequest = [GADRequest request];

[bannerView_ loadRequest:adRequest];

// start game

cocos2d::CCApplication::sharedApplication()->run();

5. we are not over Yet!!!

You‘ll have exceptions if running the app now. You must do this:

(http://stackoverflow.com/questions/12635283/admob-crashes-with-gadobjectprivate-changestate-unrecognized-selector)

You need to add -ObjC to
the Other Linker Flags of your application target‘s build setting:

  1. Click the blue top-level project icon in XCode
  2. Choose your target and go to Build Settings
  3. Under Other Linker Flags add -ObjC for
    both Release and Debug

Done!!!

Let‘s make money and go IPO :)

时间: 2024-12-16 22:43:54

add Admob with Cocos2d-x on iOS的相关文章

Add admob advertisement for Google Play Service

1. Add and reference the Google Play services library project a. Right click on your app project in Eclipse and select Properties. b. Select Android and then click Add.... Find the   google-play-services_lib project and select OK to add the  Google P

iOS项目添加.pch文件 / How to add a .pch file to an iOS project

1.Create a .pch file. 2.Write your macro, headfiles or something. Here is my prefixHeader.pch 3.Choose the Project and select "Build Settings" >>> find with keywords "prefix" >>>make the "Precompile Prefix Header

如何使用PhoneGap程序将AdMob广告嵌入到你的HTML5 iOS游戏中

如果你没有AdMob账户,先注册一个AdMob账户. 点击“Monetize new app”按钮. 如果它是一个新的应用程序,你仍然要发布,选择“Add your app manually”选项卡,命名你的应用程序,在这种情况下选择platform – iOS,然后点击“Add app”选择广告形式,像你展示如何创建一个插播广告,给它命名并保存,这个过程和横幅是相同的.你应该添加他们. 写下你的广告单元ID,如果你还没有的话,就创建横幅广告类型.你应该结束有两个广告单元的ID,一个为横幅,另一

iOS开发常用三方库、插件、知名博客等等

TimLiu-iOS   Swift版本点击这里 欢迎加入QQ交流群: 594119878 介绍 这是一个用于iOS开发的各种开源库.开源资料.开源技术等等的索引库. github排名 https://github.com/trending,github搜索:https://github.com/search 使用方法 根据目录关键字搜索,记得包含@,以保证搜索目录关键字的唯一性. 问题反馈 期待大家和我们一起共同维护,同时也期望大家随时能提出宝贵的意见(直接提交issues即可).请广大网友只

Google推出iOS功能性UI测试框架EarlGrey

经过了一段时间的酝酿后,Google很高兴地宣布了EarlGrey,一款针对于iOS的功能性UI测试框架.诸如YouTube.Google Calendar.Google Photos.Google Translate.Google Play Music等多款Google应用都成功地采用了EarlGrey框架来满足其功能性测试之所需. EarlGre的特点 EarlGrey所提供的主要特性如下所示,这些特性使得应用的测试变得更加轻松,也更具效率: 强大的内建同步机制:测试会在与UI进行交互前自动

iOS开发-常用第三方开源框架介绍(你了解的ios只是冰山一角)

iOS开发-常用第三方开源框架介绍(你了解的ios只是冰山一角) 2015-04-05 15:25 2482人阅读 评论(1) 收藏 举报开源框架 图像: 1.图片浏览控件MWPhotoBrowser       实现了一个照片浏览器类似 iOS 自带的相册应用,可显示来自手机的图片或者是网络图片,可自动从网络下载图片并进行缓存.可对图片进行缩放等操作.      下载:https://github.com/mwaterfall/MWPhotoBrowser目前比较活跃的社区仍旧是Github,

iOS开发之CocoaPods的使用

透明色:00ff00ff //设置柱状图的颜色                ColorSet cs = new ColorSet();                cs.Id = "colorset1"; #region 设置柱状图的颜色 待开发                    string strColor = oYAXIS.Color;                    switch (strColor)                    {           

常用iOS的第三方框架

图像:1.图片浏览控件MWPhotoBrowser       实现了一个照片浏览器类似 iOS 自带的相册应用,可显示来自手机的图片或者是网络图片,可自动从网络下载图片并进行缓存.可对图片进行缩放等操作.      下载:https://github.com/mwaterfall/MWPhotoBrowser 目前比较活跃的社区仍旧是Github,除此以外也有一些不错的库散落在Google Code.SourceForge等地方.由于Github社区太过主流,这里主要介绍一下Github里面流

很好的iOS学习资料

https://github.com/vsouza/awesome-ios 汇集了很多好的资料 https://github.com/vsouza/awesome-ios Skip to content This repository Pull requests Issues Gist You don’t have any verified emails. We recommend verifying at least one email. Email verification helps ou