跳转到主要内容
PRODUCT DOCUMENTS

快速找到所需文档,高效完成接入与排障

浏览产品文档与友盟 Skill,展开目录并阅读正文。

开屏广告

简介

开屏广告以App启动为时机展示广告,展示或相应结束进入首页。【渲染方式:模板渲染】

主要API

使用说明:创建UMUnionSplashAd对象来加载广告,通过设置UMUnionSplashAdDelegate代理,获取广告相关回调。

代理回调方法说明

@protocol UMUnionSplashAdDelegate <NSObject>
@optional
/// 请求广告数据成功回调
- (void)uadSplashDidLoad:(UMUnionSplashAd *)splashAd;

/// 请求广告数据失败回调
/// @param error 失败信息
- (void)uadSplashDidLoad:(UMUnionSplashAd *)splashAd failWithError:(NSError *_Nullable)error;

/// 开屏广告渲染成功回调
/// 回调说明:媒体收到此回调后调用show接口
- (void)uadSplashRenderSuccess:(UMUnionSplashAd *)splashAd;

/// 开屏广告渲染失败回调
/// 可能情况:渲染失败、展示时产生的异常
/// @param error 失败信息
- (void)uadSplashRenderFail:(UMUnionSplashAd *)splashAd error:(NSError *_Nullable)error;

/// 广告显示回调
- (void)uadSplashExposeSuccess:(UMUnionSplashAd *)splashAd;

/// 广告点击回调
- (void)uadSplashClicked:(UMUnionSplashAd *)splashAd;

/// 广告关闭回调
- (void)uadSplashClose:(UMUnionSplashAd *)splashAd;

/// 广告剩余时间(s)
- (void)uadSplashTime:(NSUInteger)time;

/// 视频广告播放状态回调
- (void)uadSplash:(UMUnionSplashAd *)splashAd mediaPlayerStatus:(UMUnionMediaPlayerStatus)status;

/// 广告详情页即将打开
- (void)uadSplashDetailViewWillPresent:(UMUnionSplashAd *)splashAd;

/// 广告详情页关闭
- (void)uadSplashViewDetailViewClosed:(UMUnionSplashAd *)splashAd;

@end

在实现上述事件回调之前,请务必先设置delegate:

splashAd.delegate = self;

调用接口说明

方法

说明

- (instancetype)initWithSlotId:(NSString *)slotId;

UMUnionSplashAd实例构造方法,slotId为对应广告位id

- (void)loadAd;

广告请求

- (void)showAdInWindow:(UIWindow *)window withBottomView:(nullableUIView *)bottomView skipView:(nullableUIView *)skipView;

展示半屏广告,调用此方法前需确保uadSplashDidLoad:已回调,window:展示开屏的容器,bottomView:自定义底部View,skipView:自定义”跳过“View

- (void)showFullScreenAdInWindow:(UIWindow *)window skipView:(nullableUIView *)skipView;

展示全屏广告,调用此方法前需确保uadSplashDidLoad:已回调,window:展示开屏的容器,skipView:自定义”跳过“View

- (NSNumber *)eCPM;

出价策略有两种:1、PD约定价格,此时该字段返回固定值 -1 ,结算以合同约定的价格为准(可能是CPM固定价,可能是CPM阶梯价,也可能是CPC/CPS等);2、RTB价格,此时该字段返回实时出价,结算以此价格为依据。

- (void)muteEnable:(BOOL)flag;

视频类广告播放静音开关 YES:静音

@property(nonatomic, assign) CGFloattimeout;

拉取广告超时时间,默认为5秒,如果拉取成功,立马展示开屏广告,否则放弃此次广告展示。

@property(nonatomic, assign) BOOL disableShake;

关闭摇一摇

接入代码示例

self.splashAd = [[UMUnionSplashAd alloc] initWithSlotId:YOUR_SLOT_ID];
self.splashAd.delegate = self;
//拉取广告超时时间,默认为5秒
self.splashAd.timeout = 2.5;
[self.splashAd loadAd];

...
    
//展示半屏广告
CGFloat bottomVHeight = 100;
if (bottomVHeight > 0 && bottomVHeight <= [[UIScreen mainScreen] bounds].size.height * 0.25) {
    UIButton *bottomBtn = [[UIButton alloc] init];
    bottomBtn.bounds = CGRectMake(0, 0, self.view.frame.size.width, bottomVHeight);
    [bottomBtn setTitle:@"流量联盟Demo" forState:UIControlStateNormal];
    [bottomBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [bottomBtn setImage:[UIImage imageNamed:@"ic_launcher"] forState:UIControlStateNormal];
    bottomBtn.userInteractionEnabled = NO;
    UILabel *skipL = [[UILabel alloc] initWithFrame:CGRectMake(200, 50, 50, 35)];
    skipL.text = @"跳过";
    skipL.textColor = [UIColor blueColor];
    skipL.backgroundColor = [UIColor lightGrayColor];
    [self.splashAd showAdInWindow:window withBottomView:bottomBtn skipView:skipL];
}
//展示全屏广告
[self.splashAd showFullScreenAdInWindow:window skipView:nil];