ios开发笔记如何在iphone-and-ipad应用程序添加admob
转自: https://lwxshow.com/post/1474.html
AdMob是另一家移动电话广告市场,现在已被Google收购。借助AdMob, 谷歌计划将其网络搜索主导地位从电脑平台扩展向手机平台。
正因为AdMob现在是Google的了,所以在Android上得到广泛的应用,不过在iPhone上也是同样可以使用的。下面就介绍一下使用方法。
其实步骤很简单:在AdMob上注册用户→登陆你的程序→得到程序固有的Publisher ID→下载并在程序中组入相应代码。
登陆
1.首先注册用户
2.注册并登陆之后,需要登记你准备添加广告的程序(这里,即使程序还没有开发完毕也没有关系)。点击下图marketplace→添加site/Application
3.选择iPhone/iPad程序,如果是Android的话就选择Android应用程序。
4.接下来填写程序的详细信息。
其中关于程序的URL的填写,如果程序已经发布,那么填写App Store上的URL,否则随便先填一个,以后可以修改。
接下来就可以得到程序的Publisher ID,其使用方法会在下面介绍。
5.同时,我们可以下载最新的SDK。(其实也可以通过这里下载)
下载并解压之后,会得到如下图的几个文件。其中README.txt有环境说明,文档及例程的下载URL。
注意点
接下来我们看看程序中怎么使用该SDK。首先我们看看例程中有哪些需要注意的。
6.MY BANNER_UNIT_ID的设定
例程中有下面这样的定义(BannerExampleViewController.m)。
#if !defined(MY_BANNER_UNIT_ID)
#error "You must define MY_BANNER_UNIT_ID as your AdMob Publisher ID"
#endif
这里就需要上面介绍的注册时得到的程序专有的Publisher ID。没有它,编译的时候将报错。类似下面的样子,我们设定一下。
#define MY_BANNER_UNIT_ID @"xxxxxxxxxxxxxxx"
#if !defined(MY_BANNER_UNIT_ID)
#error "You must define MY_BANNER_UNIT_ID as your AdMob Publisher ID"
#endif
7.另外,还有一个测试时用的属性
测试的时候将 GADRequest::testing 属性置为 YES。如下For Testing的设置。
// 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 = self;
[self.view addSubview:bannerView_];
// For Testing
GADRequest *rq = [GADRequest request];
rq.testing = YES;
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:rq];
8.效果预览
ios开发笔记如何在iphone-and-ipad应用程序添加admob相关推荐
- iOS 14:如何在iPhone和iPad上增强语音备忘录录音
iOS 14:如何在iPhone和iPad上增强语音备忘录录音 在iOS 14中进行的较小改进之一是,用户可以增强Voice Memos应用程序中的录音功能. 新的增强录制选项是一种一键式功能,可尝试 ...
- ipad iphone开发_如何在iPhone或iPad上使用Adobe Flash
ipad iphone开发 Khamosh Pathak Khamosh Pathak Growing up, you might have come across Flash while playi ...
- ipad iphone开发_如何在iPhone或iPad上查看照片的EXIF元数据
ipad iphone开发 If you want to get more information about a photo you took, there's an easy way to do ...
- ipad iphone开发_如何在iPhone或iPad上编辑视频
ipad iphone开发 TRMK/ShutterstockTRMK /快门 It's easier than ever to edit and share videos directly from ...
- ipad iphone开发_如何在iPhone或iPad上取消应用订阅
ipad iphone开发 Apple's App Store is full of apps with in-app subscriptions. That's great news for dev ...
- ipad iphone开发_如何在iPhone或iPad上快速找到应用
ipad iphone开发 Justin Duino 贾斯汀·杜伊诺(Justin Duino) Apple's App Store features around two million apps ...
- ipad iphone开发_如何在iPhone或iPad上禁用通知
ipad iphone开发 iPhone and iPad apps have to get your permission to send notifications, but it's still ...
- ipad iphone开发_如何在iPhone或iPad上更改应用程序的语言
ipad iphone开发 BigTunaOnline/Shutterstock.comBigTunaOnline / Shutterstock.com Apple's iOS 13 makes th ...
- ipad iphone开发_如何在iPhone或iPad上更改DNS服务器
ipad iphone开发 Your iPhone or iPad normally uses the DNS servers provided by whatever Wi-Fi network y ...
- ipad iphone开发_如何在iPhone或iPad上“不信任”计算机
ipad iphone开发 When you first plug your iPhone or iPad into a computer, you'll be prompted to "t ...
最新文章
- MATLAB基本操作(三):数据类型
- log4j添加日志一定记住在工程的web.xml文件下加一些内容
- Airtest自动化测试工具介绍
- Freemarker自定义标签
- plsql如何显示表结构图_产品经理需了解的架构图/结构图知识
- RS 纠删码为什么可以提高分布式存储可靠性?| 原力计划
- Visual Studio 2017 RC版发布 自带iOS模拟器
- 离线中技术方案的场景
- python输出关键字的行号_python 《第七谈》简单的抓取数据,联行号为例
- 线下盛会|欢迎关注 Pulsar Summit 2022 旧金山峰会
- 视频在线点播功能如何实现?
- 我的TOM邮箱收件速度真不慢——邮箱常见问题解答大全!
- 基于字典的中文分词算法RMM
- Android:辅助功能(模拟点击,模拟手势)入门基本学习
- Armadillo | 复数小记
- 快乐并成长着的2011年
- 聊聊引擎底层如何实现Bloom渲染算法
- 近几年一直流行说的DSP具体是什么,为什么大家都在关注
- 关联规则Apriori 流程以及思想
- 怎样查看自己的hadoop版本