IOS应用加视频广告教程

编码前的准备

在阅读这篇教程之前,请先阅读 ios接入广告基础教程 了解 如何获得广告管理库 怎么安装广告管理库

编写接入广告代码

1.首先import keymob相关的类
 #import <KeymobAd/KeymobAd.h>
2.设置各个广告平台的参数
平台参数以json的格式组织,样子如下。
    	{
		"isTesting":true,//是否是测试模式
		"rateModel":1,//广告平台排序规则,0表示priority是权重,各个平台按比例显示广告,1表示priority是顺序,各个平台按顺序展示广告
		"platforms":[
		{"class":"AdmobAdapter","priority":90,"key1":"ca-app-pub-xxx/xxx","key2":"ca-app-pub-xxx/xxx"},//admob 平台 ,key1 banner ID,key2全屏id
		{"class":"AmazonAdapter","priority":20,"key1":"xxx"},//amazon 平台 ,key1 appkey
		{"class":"ChartboostAdapter","priority":40,"key1":"xxx","key2":"xxx"},//chartboost 平台 ,key1 appID,key2 signature
		{"class":"InmobiAdapter","priority":50,"key1":"xxx"},//inmobi 平台 ,key1 appid
		{"class":"IadAdapter","priority":50,"key1":"877393773"},//iad 平台 ,android上会被自动忽略
		{"class":"KeymobAdapter","priority":50,"key1":"appid"},//keymob.com 自售广告,交叉推广需要
		{"class":"BaiduAdapter","priority":50,"key1":"appsid","key2":"appsec"},//baidu 平台
    {"class":"GDTAdapter","priority":50,"key1":"appid","key2":"banner id","param":"full id"},//广点通 平台
    {"class":"AdcolonyAdapter","priority":50,"key1":"appid","key2":"full id","param":"video id"},//adcolony 平台
		{"class":"MMediaAdapter","priority":10,"key1":"xxx","key2":"xxx"}//mmedia 平台 ,key1 banner ID,key2全屏id
		]
	}
3.初始化Keymob
初始化Keymob管理库是调用其他广告功能函数的前提,必须先初始化才能做别的调用,下面是使用Keymob.com 服务的初始化方式
    [[AdManager sharedInstance] setController: self andListener: [[AdListener alloc] init]];
    [[AdManager sharedInstance] configWithJSON: jsonString];
4.加载视频广告
[[AdManager sharedInstance] loadVideo];
5.检查视频广告是否加载成功
[[AdManager sharedInstance] isVideoReady];
6.展示视频广告
[[AdManager sharedInstance] showVideo];
7.安卓显示视频广告
显示广告前先加载,加载完成了再显示,整体就是下面的样式
   if([[AdManager sharedInstance] isVideoReady]){
            [[AdManager sharedInstance] showVideo];
        }else{
            [[AdManager sharedInstance] loadVideo];
        }

更多手机应用接入广告教程   qq交流群 310513042   返回首页