//导入头文件
#import <AnyThinkSplash/AnyThinkSplash.h>
@interface SplashVC () <ATSplashDelegate>
@end
@implementation SplashVC
//广告位ID
#define SplashPlacementID @"b67f4ab43d2fe1"
//场景ID,可选,可在后台生成。没有可传入空字符串
#define SplashSceneID @""
#pragma mark - Load Ad 加载广告
/// 加载广告
- (void)loadAd {
NSMutableDictionary *loadConfigDict = [NSMutableDictionary dictionary];
//开屏超时时间
[loadConfigDict setValue:@(8) forKey:kATSplashExtraTolerateTimeoutKey];
//自定义load参数
[loadConfigDict setValue:@"media_val_SplashVC" forKey:kATAdLoadingExtraMediaExtraKey];
[[ATAdManager sharedManager] loadADWithPlacementID:SplashPlacementID
extra:loadConfigDict
delegate:self
containerView:[self footLogoView]];
}
/// 可选接入开屏底部LogoView
- (UIView *)footLogoView {
//宽度为屏幕宽度,高度<=25%的屏幕高度(根据广告平台要求而定)
UIView * footerCtrView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kOrientationScreenWidth, 120)];
footerCtrView.backgroundColor = UIColor.whiteColor;
//添加图片
UIImageView * logoImageView = [UIImageView new];
logoImageView.image = [UIImage imageNamed:@"logo"];
logoImageView.contentMode = UIViewContentModeCenter;
logoImageView.frame = footerCtrView.frame;
[footerCtrView addSubview:logoImageView];
//添加点击事件
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(footerImgClick:)];
logoImageView.userInteractionEnabled = YES;
[logoImageView addGestureRecognizer:tap];
return footerCtrView;
}
/// footer点击事件
- (void)footerImgClick:(UITapGestureRecognizer *)tap {
ATDemoLog(@"footer click !!");
}
/// 开屏广告加载完成
/// - Parameters:
/// - placementID: 广告位ID
/// - isTimeout: 是否超时
- (void)didFinishLoadingSplashADWithPlacementID:(NSString *)placementID isTimeout:(BOOL)isTimeout {
if (!isTimeout) {
//加载成功,没有超时
}else {
//加载成功,但超时了
}
}
/// 广告位加载失败
/// - Parameters:
/// - placementID: 广告位ID
/// - error: 错误信息
- (void)didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
}
/// 开屏广告加载超时
/// - Parameter placementID: 广告位ID
- (void)didTimeoutLoadingSplashADWithPlacementID:(NSString *)placementID {
}
#pragma mark - Show Ad 展示广告
- (void)showSplash {
//场景统计功能,呈现在后台的 数据报表 -> 漏斗分析报表 -> 到达广告场景 ,在展示广告前调用。可选接入
[[ATAdManager sharedManager] entrySplashScenarioWithPlacementID:SplashPlacementID scene:SplashSceneID];
//检查是否有就绪
if (![[ATAdManager sharedManager] splashReadyForPlacementID:SplashPlacementID]) {
[self loadAd];
return;
}
//展示配置,Scene传入后台的场景ID,没有可传入空字符串,showCustomExt参数可传入自定义参数字符串
ATShowConfig *config = [[ATShowConfig alloc] initWithScene:SplashSceneID showCustomExt:@"testShowCustomExt"];
//开屏相关参数配置
NSMutableDictionary *configDict = [NSMutableDictionary dictionary];
//展示广告,在App原window中展示
[[ATAdManager sharedManager] showSplashWithPlacementID:SplashPlacementID config:config window:[UIApplication sharedApplication].keyWindow inViewController:self.tabBarController extra:configDict delegate:self];
}
/// 获得展示收益
/// - Parameters:
/// - placementID: 广告位ID
/// - extra: 额外信息字典
- (void)didRevenueForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
}
/// 开屏广告已展示
/// - Parameters:
/// - placementID: 广告位ID
/// - extra: 额外信息
- (void)splashDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
}
/// 开屏广告已关闭
/// - Parameters:
/// - placementID: 广告位ID
/// - extra: 额外信息
- (void)splashDidCloseForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
// 热启动预加载(可选)
// [self loadAd];
}
/// 开屏广告已点击
/// - Parameters:
/// - placementID: 广告位ID
/// - extra: 额外信息
- (void)splashDidClickForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
}
/// 开屏广告展示失败
/// - Parameters:
/// - placementID: 广告位ID
/// - error: 错误信息
/// - extra: 额外信息
- (void)splashDidShowFailedForPlacementID:(NSString*)placementID error:(NSError *)error extra:(NSDictionary *)extra {
}
/// 开屏广告已打开或跳转深链接页面
/// - Parameters:
/// - placementID: 广告位ID
/// - extra: 额外信息
/// - success: 是否成功
- (void)splashDeepLinkOrJumpForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra result:(BOOL)success {
}
/// 开屏广告详情页已关闭
/// - Parameters:
/// - placementID: 广告位ID
/// - extra: 额外信息
- (void)splashDetailDidClosedForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
}
/// 开屏广告关闭计时
/// - Parameters:
/// - countdown: 剩余秒数
/// - placementID: 广告位ID
/// - extra: 额外信息
- (void)splashCountdownTime:(NSInteger)countdown forPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
}
/// 开屏广告zoomout view已点击,仅Pangle 腾讯优量汇 V+支持
/// - Parameters:
/// - placementID: 广告位ID
/// - extra: 额外信息
- (void)splashZoomOutViewDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
}
/// 开屏广告zoomout view已关闭,仅Pangle 腾讯优量汇 V+支持
/// - Parameters:
/// - placementID: 广告位ID
/// - extra: 额外信息
- (void)splashZoomOutViewDidCloseForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
}