插播式广告是在app运行过程中自然断点处投放的全屏广告。不动产业务采用此类广告量是采用横幅广告的10倍。插播式广告可以切实吸引用户的注意,并为你的移动业务带来利润。
按照以下步骤开始利用插播式广告盈利:
在添加app后,选择 INTERSTITIAL ,创建一个放置,将广告类型设置为Interstitial(插播式)。
创建插播式广告放置之后,将生成放置id。
The IMInterstitial
仅仅只是 UIViewController
的一个子类,根据用户操作播放全屏广告。
按照以下步骤以编程方式创建插播式广告单元:
在你的 ViewController.h
文件中导入框架,并声明一个interstitial(插播)实例。 你的 ViewController
文件应该如下:
#import <uikit uikit.h="">
@import InMobiSDK;
@interface ViewController : UIViewController <iminterstitialdelegate>
@property (nonatomic, strong) IMInterstitial *interstitial;
@end
</iminterstitialdelegate></uikit>
实例化插播对象。你的ViewController.m
文件中的 viewDidLoad
函数应该如下:
-(void)viewDidLoad {
[super viewDidLoad];
self. interstitial = [[IMInterstitial alloc] initWithPlacementId:@"Insert your placement ID here"];
self. interstitial.delegate = self;
[self.interstitial load];
}
重点: 每个放置ID仅创建一个对象,在接下来的广告加载中重复使用。
广告状态回调时,执行IMInterstitial
的委托性能。支持以下回调函数:
/*Indicates that the interstitial is ready to be shown */
- (void)interstitialDidFinishLoading:(IMInterstitial *)interstitial {
NSLog(@"interstitialDidFinishLoading");
}
/* Indicates that the interstitial has failed to receive an ad. */
- (void)interstitial:(IMInterstitial *)interstitial didFailToLoadWithError:(IMRequestStatus *)error {
NSLog(@"Interstitial failed to load ad");
NSLog(@"Error : %@",error.description);
}
/* Indicates that the interstitial has failed to present itself. */
- (void)interstitial:(IMInterstitial *)interstitial didFailToPresentWithError:(IMRequestStatus *)error {
NSLog(@"Interstitial didFailToPresentWithError");
NSLog(@"Error : %@",error.description);
}
/* indicates that the interstitial is going to present itself. */
- (void)interstitialWillPresent:(IMInterstitial *)interstitial {
NSLog(@"interstitialWillPresent");
}
/* Indicates that the interstitial has presented itself */
- (void)interstitialDidPresent:(IMInterstitial *)interstitial {
NSLog(@"interstitialDidPresent");
}
/* Indicates that the interstitial is going to dismiss itself. */
- (void)interstitialWillDismiss:(IMInterstitial *)interstitial {
NSLog(@"interstitialWillDismiss");
}
/* Indicates that the interstitial has dismissed itself. */
- (void)interstitialDidDismiss:(IMInterstitial *)interstitial {
NSLog(@"interstitialDidDismiss");
}
/* Indicates that the user will leave the app. */
- (void)userWillLeaveApplicationFromInterstitial:(IMInterstitial *)interstitial {
NSLog(@"userWillLeaveApplicationFromInterstitial");
}
/* interstitial:didInteractWithParams: Indicates that the interstitial was interacted with. */
- (void)interstitial:(IMInterstitial *)interstitial didInteractWithParams:(NSDictionary *)params {
NSLog(@"InterstitialDidInteractWithParams");
}
/ * Not used for direct integration. Notifies the delegate that the ad server has returned an ad but assets are not yet available. */
- (void)interstitialDidReceiveAd:(IMInterstitial *)interstitial {
NSLog(@"interstitialDidReceiveAd");
}
使用下列代码显示插播式广告:
[self.interstitial showFromViewController:self];
//[self.interstitial showFromViewController:self withAnimation:kIMInterstitialAnimationTypeCoverVertical];
以下是可能的动画类型:
kIMInterstitialAnimationTypeCoverVertical
kIMInterstitialAnimationTypeFlipHorizontal
kIMInterstitialAnimationTypeNone
Important:
interstitialDidFinishLoading
委托已触发(从showFromViewController
。否则将触发插播错误回调 interstitial:didFailToPresentScreenWithError:
。保持监听插播组态,仅在广告加载完毕后调用显示。[self.interstitial load];
,否则无法再次调用显示showFromViewController
。选择工具(Tools)-诊断(Diagnostics),将测试模式设为 Global ON或者Selective ON。
如果你是第一次集成某个广告单元 | 将测试模式 ( Test Mode)设为 Global ON。 |
如果你希望有选择性地为某组设备打开测试流量 你之前已经为某广告单元集成过SDK,因此你应该把测试局限于几个设备 |
Set 将测试模式( Test Mode)设为Selective ON。
设备部分:
如果你已经配置过某个设备,你可以选择这个设备,测试模式将激活。 |
注意: 在启动前你必须关闭测试模式,否则你将无法利用你的app盈利。
现在你已经准备好测试广告了。
获取设备ID
设备id就是IDFA或者IFA(广告标识符)。获取设备ID最简单的函数就是将SDK的日志级别设为“调试(debug)”。为激活这些调试日志,请在 AppDelegate.m
文件的didFinishLaunchingWithOptions
函数中添加以下内容:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Initialize InMobi SDK with your account ID
[IMSdk initWithAccountID:@"Insert InMobi account ID here"];
//Set log level to Debug
[IMSdk setLogLevel:kIMSDKLogLevelDebug];
// Do your stuff.
return YES;
}
处于调试模式时,在Xcode开发者控制台登陆的设备ID为: “Publisher device ID is <device-id>”</device-id>
。
你可以在 Device ID对话框中输入该设备id。
[InMobi] InMobi SDK初始化账户id: <这里是你的账户id>
[InMobi] 读取插播式广告获知放置id: <这里是你的放置id>
[InMobi] 发行者设备id是 <这里是设备id>
[InMobi] 成功读取插播式广告获知放置id: <这里是你的放置id >
** 错误 ** [InMobi] ___ 请在创建
** 错误 ** [InMobi] ___ 账户id不能为零或空值。请提供有效的账户id。
[InMobi] 无效的账户id无法初始化。请提供有效的账户id。
下表中为全套关键日志。
初始化SDK
情境 | 日志级别 | 日志 |
发行者传递零值或空值账户id | 错误 | 账户id不能为零或空值。请提供有效的账户id。 |
发行者传递有效的账户id | 调试 | InMobi SDK初始化账户id: <账户id> |
发行者传递无效的账户id | 错误 | 无效的账户id无法初始化。请提供有效的账户id。 |
有更新版本的SDK可使用 | 调试 | 有新版本 (ver. 6.0.0) 的InMobi SDK可使用!你现在使用的为旧版(ver. 5.3.1)。从 http://www.inmobi.com/products/sdk/#downloads下载最新版本的InMobi SDK。 |
普通广告
情境 | 日志级别 | 日志 |
无网络连接时发送广告请求 | 错误 | 此时网络连接不可以。请重试。 |
广告处于加载中或广告可看时发送广告请求 | 错误 | 广告正在加载,请等待加载完成再请求下一个广告(放置id : <placement id="" /> )。 |
用户浏览时发送广告请求 | 错误 | 用户正在浏览广告,请等待用户关闭再请求下一个广告(放置id : <placement id="" /> )。 |
发行者设备Id | 调试 | 发行者设备id是<device id="" /> |
插播式广告
情境 | 日志级别 | 日志 |
发行者在未初始化SDK时创建插播 | 错误 | 请在创建插播式广告前初始化SDK |
发行者使用无效的放置id创建插播 | 错误 | 请提供有效的放置id以创建插播式广告 |
发行者访问加载某插播式广告 | 调试 | 读取插播式广告获知放置id: <placement id="" /> |
成功读取广告 | 调试 | 成功读取插播式广告获知放置id: <placement id="" /> |
无法读取广告 | 错误 | 无法读取插播式广告获知放置id:<placement id="" /> 出错: <status code="" /> |
开始在web视图中加载插播式广告 | 调试 | 开始在web视图中加载插播式广告标记获知放置id: <placement id="" /> |
成功在web视图中加载插播式广告 | 调试 | 成功在web视图中加载插播式广告标记获知放置id: <placement id="" /> |
无法在web视图中加载插播式广告 | 错误 | 无法在web视图中加载插播式广告标记获知放置id: <placement id="" /> |
播放插播式广告 | 调试 | 成功播放插播式广告获知放置id: <placement id="" /> |
关闭插播式广告 | 调试 | 关闭插播式广告获知放置id: <placement id="" /> |
在就绪前显示广告 | 错误 | 广告加载不完全。请等待广告进入就绪状态后再调用显示。 |
没有视图控制器无法播放全屏广告。请传递视图控制器以显示全屏广告 | 错误 | 没有视图控制器无法播放全屏广告。请传递视图控制器以显示全屏广告。 |
充分利用游戏中的角色、主题及互动改善全屏广告体验,使插播式广告看起来就像是游戏设计的扩展部分。
为激活你的插播式广告中的自定义框架,需与InMobi插播式广告集成,并在创建插播放置时激活“Custom Frames”。
了解设备的尺寸和方向
InMobi自定义框架适用于特殊的设备尺寸和方向。这一点很重要,因为你要上传或选择与设备尺寸和方向适配的特殊框架。
注意:
了解InMobi默认模板
如果你有至少一个InMobi自定义框架,那么你将看见一个包含不同自定义框架的列表页,上面显示它们的性能指标。第一项称作InMobi Default(默认)。你不能编辑这个模板,也不能中止或删除这个单元。
在两种情况下使用InMobi默认模板:
注意: 不能关闭InMobi默认模板。
在为你的插播式广告设计自定义框架时请牢记以下规范:
设备 | 方向 | 框架尺寸 | 内容器尺寸 |
智能手机1 | 纵向 | 320x480 (RGB, 72ppi) | 240x360 |
横向 | 480x320 (RGB, 72ppi) | 360x240 | |
智能手机2 | 纵向 | 320x568 (RGB, 72ppi) | 250x444 |
横向 | 568x320 (RGB, 72ppi) | 444x250 | |
平板电脑1 | 纵向 | 768x1024 (RGB, 72ppi) | 576x768 |
横向 | 1024x768 (RGB, 72ppi) | 768x576 | |
平板电脑2 | 纵向 | 800x1280 (RGB, 72ppi) | 600x960 |
横向 | 1280x800 (RGB, 72ppi) | 960x600 |
注意:
创建多样理念(例如不同的颜色、不同的角色、有无动画等),为同一插播式广告试用自定义框架,并展示效果。