iOS-插入广告-InMobi使用教程
来源:互联网 发布:httpclient工具类json 编辑:程序博客网 时间:2024/05/17 08:20
由于苹果停止iAd,目前最方便的只有用InMobi了
教程如下:
网页部分
首先,你要能翻墙,方式不赘述,我用到Lantern,每月免费500M,基本够用。
InMobi官网看着像中国本地化了,但是注册不知道为什么收不到验证码,坑爹呢。但是下载sdk没问题(关于sdk,你pod也可以下载也可以,看你自己喜好啦,由于我不太喜欢pod所以下载的sdk,如有反感可以点x了)。我用的google账号登录的,实在不行自己去注册一个Google账号。
填写完毕之后按照引导,创建完你的app,一般来说新应用添加广告应该都还没上架,这里要写上你的app名称,上架的填你app的url就行了。这个时候上面有一排字,让你填信息的,有两个,第一个个人信息,第二个就是关键之处,银行卡信息(银行swift code传送门)。
强烈建议使用banner(横幅)模式要不然很恶心
这个时候,要记得复制两个东西出来备用:
一
位置ID,如下图
先点这里
复制红条位置的位置ID
(如果有多个我也不知道该怎么用,你先复制下来再说呗,应该就是每个bannerView对应一个位置ID,反正我是这样的,而且两个分开计费)
二
你账号的ID
这两个ID复制备用,然后就可以来到Xcode里了。
Xcode部分
首先,导入sdk。右键项目,add files to..选择这个玩意儿。
InMobiSDK.framework
记得选择copy,确定。
然后在Build phases的Link Binary…中 还需要添加下面两个库
Info里面添加两个key,如下
1
2(这个主要是需要根据地理位置获得广告信息的,我用的时候没有提示,随便写值就好了)
接下来进入主题,使用。
在AppDelegate.h中:
@import InMobiSDK;
AppDelegate.m中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [IMSdk initWithAccountID:@"刚刚复制下来的你的accountID"]; return YES;}
创建广告(以banner为例)
同样,在你需要添加广告的Controller中先导入sdk
@import InMobiSDK;
添加delegate
<IMBannerDelegate>
创建视图:
self.banner = [[IMBanner alloc] initWithFrame:CGRectMake(0,400, 320, 50) placementId:1493267833946]; self.banner.delegate = self; [self.view addSubview:self.banner]; [self.banner load];
然后是一些代理方法(建议不管有没有用,写上先,强迫症表示看到一堆警告⚠️很不舒服)
#pragma mark -------------------- 广告 ----------------------/*Indicates that the banner has received an ad. */- (void)bannerDidFinishLoading:(IMBanner *)banner { NSLog(@"bannerDidFinishLoading");}/* Indicates that the banner has failed to receive an ad */- (void)banner:(IMBanner *)banner didFailToLoadWithError:(IMRequestStatus *)error { NSLog(@"banner failed to load ad"); NSLog(@"Error : %@", error.description);}/* Indicates that the banner is going to present a screen. */- (void)bannerWillPresentScreen:(IMBanner *)banner { NSLog(@"bannerWillPresentScreen");}/* Indicates that the banner has presented a screen. */- (void)bannerDidPresentScreen:(IMBanner *)banner { NSLog(@"bannerDidPresentScreen");}/* Indicates that the banner is going to dismiss the presented screen. */- (void)bannerWillDismissScreen:(IMBanner *)banner { NSLog(@"bannerWillDismissScreen");}/* Indicates that the banner has dismissed a screen. */- (void)bannerDidDismissScreen:(IMBanner *)banner { NSLog(@"bannerDidDismissScreen");}/* Indicates that the user will leave the app. */- (void)userWillLeaveApplicationFromBanner:(IMBanner *)banner { NSLog(@"userWillLeaveApplicationFromBanner");}/* Indicates that the banner was interacted with. */-(void)banner:(IMBanner *)banner didInteractWithParams:(NSDictionary *)params{ NSLog(@"bannerdidInteractWithParams");}/*Indicates that the user has completed the action to be incentivised with .*/-(void)banner:(IMBanner*)banner rewardActionCompletedWithRewards:(NSDictionary*)rewards{ NSLog(@"rewardActionCompletedWithRewards");}
command + R 就能看到广告了。横幅(banner)广告默认60秒刷新一次。
使用:
banner.keywords = @"sports, cars, bikes";//设置显示广告的类型/* 设置刷新频率(最低20,应该就是按你请求广告次数算钱的吧,不过貌似有bug,频率过高的话就刷不出来了,所以建议这个值不要太小,30~50吧) */banner.refreshInterval = 20;[banner shouldAutoRefresh:YES];//设置是否自动刷新
==================================
4.28更新
==================================
app成功上架之后,需要添加url,鼓捣半天,终于成功,步骤如下
iTunes connect中:
然后来到InMobi,点击中间的monetize,
步骤就是这样的啦,最后上一张效果图
最后的最后,安利一个我的app,图中取字,一个利用百度文字识别复制图片中的文字的app,由于简书贴链接被封了,所以还请大家自行App Store了
谢谢大家。
- iOS-插入广告-InMobi使用教程
- iOS开发 接入InMobi广告平台的一些个人经验
- 多平台开发 JavaScript 接入ios原生 inMobi 广告
- iOS 插入广告
- 如何集成inmobi到ios
- 如何集成inmobi到ios
- IOS版Cocos2d-x2.2使用移动广告聚合平台集成插屏广告教程
- iOS 使用admob广告
- iOS 开发 初级:插入Admob 广告
- 如何优雅的插入广告-iOS篇
- Andriod中插入腾讯广告的使用
- Andriod中插入百度广告的使用
- Andriod中插入腾讯广告的使用
- IOS版AdMob集成KeyMob广告教程
- IOS版AdMob集成KeyMob广告教程
- Unity接入Admob广告教程IOS篇
- Unity接入百度广告教程IOS篇
- unity接入百度广告教程ios篇
- View的滑动方法
- Luogu P1709 [USACO5.5]隐藏口令Hidden Password
- 石家庄明天打折22309
- 辛集明天打折69449
- Android自定义控件
- iOS-插入广告-InMobi使用教程
- zb的生日(dfs)
- 百炼4105:拯救公主
- #POJ2516#Minimum Cost(拆点+Km完备匹配)
- Task failed to report status for 1200 seconds. Killing!老碰到这种问题怎么解
- 一起学ORBSLAM2(1)跑通ORBSLAM2 ubuntu 14.04的运行
- CodeForces 798B Mike and strings
- D
- 三层登录实现 C#版