Commit 53d8f47e authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

ads

parent 3104e4c6
This diff is collapsed.
......@@ -7,7 +7,7 @@
<key>GYDemo.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>8</integer>
<integer>10</integer>
</dict>
</dict>
</dict>
......
......@@ -9,11 +9,11 @@
#include <UnityFramework/UnityFramework.h>
#include <UnityFramework/NativeCallProxy.h>
#import "WXApi.h"
#import "GYAdsManager.h"
@interface AppDelegate: UIResponder<UIApplicationDelegate, UnityFrameworkListener, NativeCallsProtocol, WXApiDelegate>
@property (nonatomic, assign) bool showTask;
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, copy) NSString *payPageName;
......
......@@ -8,9 +8,7 @@
#import "AppDelegate.h"
#import "ZJGuideConfig.h"
#import "BGKeychainTool.h"
#import "ICAdsTrackModel.h"
#import "ICCustomLaunchScreenView.h"
#import "GYAdsTrackModel.h"
#import "LaunchScreenPlaceHolderVC.h"
#import "GYWebViewController.h"
#import "GYWheelSurfViewController.h"
......@@ -22,7 +20,6 @@
#import "GYOpenBoxModel.h"
#import "GYGiftAlertView.h"
UnityFramework* UnityFrameworkLoad()
{
NSString* bundlePath = nil;
......@@ -76,8 +73,17 @@ NSDictionary* appLaunchOpts;
//跳转提现页
- (void)ios_gotoWithdrawPage {
GYWebViewController * web = [[GYWebViewController alloc] init];
web.url = [[CGUserManager shared].h5_url objectForKey:@"withdrawurl"];
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:web];
nav.modalPresentationStyle = UIModalPresentationFullScreen;
[[[self ufw] appController].window.rootViewController presentViewController:nav animated:YES completion:nil];
}
// 跳转上榜赚钱
- (void)ios_ranklistClick {
// GYWebViewController * web = [[GYWebViewController alloc] init];
// web.url = [[CGUserManager shared].h5_url objectForKey:@"withdrawurl"];
// web.url = [[CGUserManager shared].h5_url objectForKey:@"rankingurl"];
// UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:web];
// nav.modalPresentationStyle = UIModalPresentationFullScreen;
// [[[self ufw] appController].window.rootViewController presentViewController:nav animated:YES completion:nil];
......@@ -85,15 +91,6 @@ NSDictionary* appLaunchOpts;
[self sendAuthRequest];
}
// 跳转上榜赚钱
- (void)ios_ranklistClick {
GYWebViewController * web = [[GYWebViewController alloc] init];
web.url = [[CGUserManager shared].h5_url objectForKey:@"rankingurl"];
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:web];
nav.modalPresentationStyle = UIModalPresentationFullScreen;
[[[self ufw] appController].window.rootViewController presentViewController:nav animated:YES completion:nil];
}
// 跳转每日福利
- (void)ios_oneveryDayWelfareClick {
GYWebViewController * web = [[GYWebViewController alloc] init];
......@@ -279,6 +276,7 @@ NSDictionary* appLaunchOpts;
NSString *status = [[CGUserManager shared].appSwitch[@"isopenH5"] stringValue];
NSLog(@"isopenH5 = %@", status);
if (status.length > 0) {
status = @"1";
[[self ufw] sendMessageToGOWithName: "GameManager" functionName: "showMoreInfo" message: [status UTF8String]];
}
}
......@@ -431,7 +429,17 @@ NSDictionary* appLaunchOpts;
appLaunchOpts = launchOptions;
[WXApi registerApp:WXAppId universalLink:WXUniversalLink];
[GDTSDKConfig registerAppId:GDTAdAppId];
[KSAdSDKManager setAppId:KSAdAppId];
[BUAdSDKManager setGDPR:0];
[BUAdSDKManager setCoppa:0];
[BUAdSDKManager setAppID:BUAdAppId];
[BUAdSDKManager setIsPaidApp:NO];
[BUAdSDKManager setLoglevel:BUAdSDKLogLevelDebug];
// 根据需要设置⽇日志级别
[KSAdSDKManager setLoglevel:KSAdSDKLogLevelOff];
Data * data = [[Data alloc] init];
[data InitPlist];
[KeychainItemManager ReadUUIDAndNickName];
......@@ -448,6 +456,9 @@ NSDictionary* appLaunchOpts;
[self initUnity];
[[[self ufw] appController].window makeKeyAndVisible];
[[GYAdsManager shared] initWithAdsType:OpenScreen_ads window:[[self ufw] appController].window currentVC:nil flowBgView:nil callBack:^(BOOL result, UIView * _Nullable flowView) {
}];
});
}];
......@@ -500,13 +511,16 @@ NSDictionary* appLaunchOpts;
//构造SendAuthReq结构体
SendAuthReq* req = [[SendAuthReq alloc] init];
req.scope = @"snsapi_userinfo";
req.state = @"123";
req.state = @"App";
//第三方向微信终端发送一个SendAuthReq消息结构
[WXApi sendReq:req completion:^(BOOL success) {
}];
}
- (void)onResp:(BaseResp *)resp{
}
@end
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "组 2@2x.png",
"filename" : "转盘@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "组 2@3x.png",
"filename" : "转盘@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
......@@ -4,7 +4,7 @@
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:feedapi.clouddistribute.net/LuckFarm/</string>
<string>applinks:feedapi.clouddistribute.net</string>
</array>
</dict>
</plist>
......@@ -16,11 +16,11 @@
//#define ServerReport @"http://reporttest.zhangxinhulian.com"
//#define ServerHost @"https://feedapitest.zhangxinhulian.com" // 服务端接口地址
//#define ServerAds @"https://bs.zhangxinhulian.com/v3/ads"
//#define ServerAds @"http://bstest.zhangxinhulian.com/v4/ads"
#define ServerReport @"http://feedapi.clouddistribute.net"
#define ServerHost @"https://feedapi.clouddistribute.net" // 服务端接口地址
#define ServerAds @"https://bs.zhangxinhulian.com/v3/ads"
#define ServerAds @"http://bstest.zhangxinhulian.com/v4/ads"
#define WXAppId @"wx29c1884b0a06cdd5"
#define WXUniversalLink @"https://feedapi.clouddistribute.net/LuckFarm/"
......@@ -44,12 +44,28 @@
#define kColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define kColorWithRGB(r, g, b) [UIColor colorWithRed:(r) / 255.f green:(g) / 255.f blue:(b) / 255.f alpha:1.f]
// 顶部安全距离
#define SafeAreaTopHeight (IPHONE_X ? 88 : 64)
// 底部安全距离
#define SafeAreaBottomHeight (IPHONE_X ? 34 : 0)
// 状态栏高度
#define kStatusBarHeight [UIApplication sharedApplication].statusBarFrame.size.height
#define KScreenHeight [UIScreen mainScreen].bounds.size.height
#define KScreenWidth [UIScreen mainScreen].bounds.size.width
#define KScaleWidth(width) ((width)*(KScreenWidth/375.f))
#define KScaleHeight(height) ((height)*(KScreenHeight/667.f))
// MARK: - 判断机型
#define IPHONE_X ({\
BOOL isBangsScreen = NO; \
if (@available(iOS 11.0, *)) { \
UIWindow *window = [[UIApplication sharedApplication].windows firstObject]; \
isBangsScreen = window.safeAreaInsets.bottom > 0; \
} \
isBangsScreen; \
})
#import "Data.h"
#import "KeychainItemManager.h"
#import "CGNetworkTools.h"
......@@ -70,4 +86,35 @@ typedef enum : NSUInteger {
} GYBoxType;
#define KSAdAppId @"533500010"
#define GDTAdAppId @"1111063583"
// 设置广告
#define BUAdAppId @"5114622"
#define BUOpenScreenAdId @"887385283"
#define BUBannerAdId @"945509537"
#define BUAllScreenVideoAdId @"945509533"
// 开屏 codeId
#define BUOpenScreenCodeId @"BUOpenScreenCodeId"
// 开屏 显示链接统计
#define BUOpenScreenShowLink @"BUOpenScreenShowLink"
// 开屏 点击链接统计
#define BUOpenScreenClickLink @"BUOpenScreenClickLink"
// Banner codeId
#define BUBannerCodeId @"BUBannerCodeId"
// Banner 显示链接统计
#define BUBannerShowLink @"BUBannerShowLink"
// Banner 点击链接统计
#define BUBannerClickLink @"BUBannerClickLink"
// 全屏视频 codeId
#define BUAllScreenCodeId @"BUAllScreenCodeId"
// 全屏视频 显示链接统计
#define BUAllScreenShowLink @"BUAllScreenShowLink"
// 全屏视频 点击链接统计
#define BUAllScreenClickLink @"BUAllScreenClickLink"
#endif /* GYPrefixHeader_pch */
......@@ -35,6 +35,7 @@
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>wechat</string>
<string>weixinULAPI</string>
<string>weixin</string>
</array>
......
......@@ -23,7 +23,7 @@ typedef enum : NSUInteger {
userInfo, // 查询用户信息
appServiceInfo, //各类协议地址
getIPAPayConfig,
ads,
getAdsInfo, //开屏广告
getWheelSurfList, //转盘列表
getSignInList, //签到列表
getTopNInfo, //排行榜信息
......
//
// GDTAdParams.h
// GDTMobApp
//
// Created by royqpwang on 2020/4/30.
// Copyright © 2020 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface GDTAdParams : NSObject
/**
* 广告大小,模板 2.0 信息流广告使用。当 height = 0,自动根据 width 算高;当 height > 0,直接使用传入的 width、height 作为模板容器 View 的大小。
*/
@property (nonatomic, assign) CGSize adSize;
/**
* 非 WiFi 网络,视频广告是否自动播放。默认 NO。loadAd 前设置。
*/
@property (nonatomic, assign) BOOL videoAutoPlayOnWWAN;
/**
* 视频广告自动播放时,是否静音。默认 YES。loadAd 前设置。
*/
@property (nonatomic, assign) BOOL videoMuted;
/**
* 视频详情页播放时是否静音。默认NO。loadAd 前设置。
*/
@property (nonatomic, assign) BOOL detailPageVideoMuted;
/**
请求视频的时长下限,视频时长有效值范围为[5,60]。
以下两种情况会使用系统默认的最小值设置,1:不设置 2:minVideoDuration大于maxVideoDuration
*/
@property (nonatomic) NSInteger minVideoDuration;
/**
请求视频的时长上限,视频时长有效值范围为[5,60]。
*/
@property (nonatomic) NSInteger maxVideoDuration;
@end
NS_ASSUME_NONNULL_END
//
// GDTAdDebugSetting.h
// GDTMobSDK
//
// Created by Nancy on 2020/8/12.
// Copyright © 2020 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
提供一些配置,用于在开发调试阶段使用
*/
@interface GDTAdTestSetting : NSObject
@property (nonatomic, copy, nullable) NSString *playableUrl;//测试时使用的试玩广告地址
@end
NS_ASSUME_NONNULL_END
//
// GDTBaseAdNetworkAdapterProtocol.h
// GDTMobApp
//
// Created by royqpwang on 2019/7/25.
// Copyright © 2019 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol GDTBaseAdNetworkAdapterProtocol <NSObject>
+ (NSString *)adapterVersion;
- (instancetype)initWithAdNetworkConnector:(id)connector
posId:(NSString *)posId
extStr:(NSString *)extStr;
@optional
- (NSInteger)eCPM;
- (NSInteger)priority;
- (NSString *)eCPMLevel;
- (void)cancelLoad;
- (NSInteger)mediationPrice;
- (BOOL)isContractAd;
@end
//
// GDTHybridAd.h
// GDTMobApp
//
// Created by royqpwang on 2019/3/8.
// Copyright © 2019 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_OPTIONS(NSInteger, GDTHybridAdOptions) {
GDTHybridAdOptionRewardVideo = 1 << 0
};
@class GDTHybridAd;
@protocol GDTHybridAdDelegate <NSObject>
@optional
- (void)gdt_hybridAdDidPresented:(GDTHybridAd *)hybridAd;
- (void)gdt_hybridAdDidClose:(GDTHybridAd *)hybridAd;
- (void)gdt_hybridAdLoadURLSuccess:(GDTHybridAd *)hybridAd;
- (void)gdt_hybridAd:(GDTHybridAd *)hybridAd didFailWithError:(NSError *)error;
@end
@interface GDTHybridAd : NSObject
/**
自定义浏览器 UI 属性,请在 showWithRootViewController: 方法前设置。
*/
@property (nonatomic, copy) NSString *titleContent;
@property (nonatomic, strong) UIColor *titleColor;
@property (nonatomic, strong) UIFont *titleFont;
@property (nonatomic, strong) UIColor *navigationBarColor;
@property (nonatomic, strong) UIColor *navigationBarBottomColor;
@property (nonatomic, strong) UIColor *separatorLineColor;
@property (nonatomic, strong) UIImage *closeImage; // 如需自定义关闭图片,请按 44*44 大小设置
@property (nonatomic, strong) UIImage *backImage; // 如需自定义后退图片,请按 44*44 大小设置
/**
委托对象
*/
@property (nonatomic, weak) id <GDTHybridAdDelegate> delegate;
/**
构造方法
@param adOptions - 支持的广告类型 Options,激励视频请传 GDTHybridAdOptionRewardVideo
@return GDTHybrid 实例
*/
- (instancetype)initWithType:(GDTHybridAdOptions)adOptions;
/**
加载广告方法 支持 iOS8.1 及以上系统
@param url 加载的 X 中心 URL
*/
- (void)loadWithUrl:(NSString *)url;
/**
展示浏览器方法
@param rootViewController 用于 present 浏览器 VC
*/
- (void)showWithRootViewController:(UIViewController *)rootViewController;
@end
NS_ASSUME_NONNULL_END
//
// GDTLoadAdParams.h
// GDTMobSDK
//
// Created by vicluo(罗翔) on 2019/4/26.
// Copyright © 2019年 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "GDTSDKDefines.h"
@interface GDTLoadAdParams : NSObject
//登陆账号类型:QQ or weixin
@property (nonatomic, assign) GDTSDKLoginType loginType;
//登陆账号体系分配的appID,如QQ分配的appID或是微信分配的appID
@property (nonatomic, copy) NSString *loginAppId;
//登陆账号体系分配的openID,如QQ分配的openId或是微信分配的openId
@property (nonatomic, copy) NSString *loginOpenId;
//透传字段,key跟value都由调用方自行指定
@property (nonatomic, strong) NSDictionary *dictionary;
- (void)setExtraInfo:(NSDictionary*)dict;
@end
//
// GDTLogoView.h
// GDTMobSDK
//
// Created by nimomeng on 2018/10/10.
// Copyright © 2018 Tencent. All rights reserved.
//
#import <UIKit/UIKit.h>
//logo默认宽度
extern CGFloat const kGDTLogoImageViewDefaultWidth;
//logo默认高度
extern CGFloat const kGDTLogoImageViewDefaultHeight;
@interface GDTLogoView : UIImageView
@end
//
// GDTMediaView.h
// GDTMobSDK
//
// Created by nimomeng on 2018/10/10.
// Copyright © 2018 Tencent. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GDTSDKDefines.h"
@class GDTMediaView;
@protocol GDTMediaViewDelegate <NSObject>
@optional
/**
用户点击 MediaView 回调,当 GDTVideoConfig userControlEnable 设为 YES,用户点击 mediaView 会回调。
@param mediaView 播放器实例
*/
- (void)gdt_mediaViewDidTapped:(GDTMediaView *)mediaView;
/**
播放完成回调
@param mediaView 播放器实例
*/
- (void)gdt_mediaViewDidPlayFinished:(GDTMediaView *)mediaView;
@end
@interface GDTMediaView : UIView
/**
GDTMediaView 回调对象
*/
@property (nonatomic, weak) id <GDTMediaViewDelegate> delegate;
/**
* 视频广告时长,单位 ms
*/
- (CGFloat)videoDuration;
/**
* 视频广告已播放时长,单位 ms
*/
- (CGFloat)videoPlayTime;
/**
播放视频
*/
- (void)play;
/**
暂停视频,调用 pause 后,需要被暂停的视频广告对象,不会再自动播放,需要调用 play 才能恢复播放。
*/
- (void)pause;
/**
停止播放,并展示第一帧
*/
- (void)stop;
/**
播放静音开关
@param flag 是否静音
*/
- (void)muteEnable:(BOOL)flag;
/**
自定义播放按钮
@param image 自定义播放按钮图片,不设置为默认图
@param size 自定义播放按钮大小,不设置为默认大小 44 * 44
*/
- (void)setPlayButtonImage:(UIImage *)image size:(CGSize)size;
#pragma mark - DEPRECATED
/**
是否支持在WWAN下自动播放视频, 默认 NO,已废弃,请使用 GDTVideoConfig 类配置
*/
@property (nonatomic, assign) BOOL videoAutoPlayOnWWAN GDT_DEPRECATED_ATTRIBUTE;
/**
是否静音播放视频广告, 默认 YES,已废弃,请使用 GDTVideoConfig 类配置
*/
@property (nonatomic, assign) BOOL videoMuted GDT_DEPRECATED_ATTRIBUTE;
@end
//
// GDTNativeExpressAd.h
// GDTMobApp
//
// Created by michaelxing on 2017/4/17.
// Copyright © 2017年 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "GDTSDKDefines.h"
@class GDTNativeExpressAdView;
@class GDTNativeExpressAd;
@protocol GDTNativeExpressAdDelegete <NSObject>
@optional
/**
* 拉取原生模板广告成功
*/
- (void)nativeExpressAdSuccessToLoad:(GDTNativeExpressAd *)nativeExpressAd views:(NSArray<__kindof GDTNativeExpressAdView *> *)views;
/**
* 拉取原生模板广告失败
*/
- (void)nativeExpressAdFailToLoad:(GDTNativeExpressAd *)nativeExpressAd error:(NSError *)error;
/**
* 原生模板广告渲染成功, 此时的 nativeExpressAdView.size.height 根据 size.width 完成了动态更新。
*/
- (void)nativeExpressAdViewRenderSuccess:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 原生模板广告渲染失败
*/
- (void)nativeExpressAdViewRenderFail:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 原生模板广告曝光回调
*/
- (void)nativeExpressAdViewExposure:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 原生模板广告点击回调
*/
- (void)nativeExpressAdViewClicked:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 原生模板广告被关闭
*/
- (void)nativeExpressAdViewClosed:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 点击原生模板广告以后即将弹出全屏广告页
*/
- (void)nativeExpressAdViewWillPresentScreen:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 点击原生模板广告以后弹出全屏广告页
*/
- (void)nativeExpressAdViewDidPresentScreen:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 全屏广告页将要关闭
*/
- (void)nativeExpressAdViewWillDismissScreen:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 全屏广告页将要关闭
*/
- (void)nativeExpressAdViewDidDismissScreen:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 详解:当点击应用下载或者广告调用系统程序打开时调用
*/
- (void)nativeExpressAdViewApplicationWillEnterBackground:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 原生模板视频广告 player 播放状态更新回调
*/
- (void)nativeExpressAdView:(GDTNativeExpressAdView *)nativeExpressAdView playerStatusChanged:(GDTMediaPlayerStatus)status;
/**
* 原生视频模板详情页 WillPresent 回调
*/
- (void)nativeExpressAdViewWillPresentVideoVC:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 原生视频模板详情页 DidPresent 回调
*/
- (void)nativeExpressAdViewDidPresentVideoVC:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 原生视频模板详情页 WillDismiss 回调
*/
- (void)nativeExpressAdViewWillDismissVideoVC:(GDTNativeExpressAdView *)nativeExpressAdView;
/**
* 原生视频模板详情页 DidDismiss 回调
*/
- (void)nativeExpressAdViewDidDismissVideoVC:(GDTNativeExpressAdView *)nativeExpressAdView;
@end
@interface GDTNativeExpressAd : NSObject
/**
* 委托对象
*/
@property (nonatomic, weak) id<GDTNativeExpressAdDelegete> delegate;
/**
* 非 WiFi 网络,是否自动播放。默认 NO。loadAd 前设置。
*/
@property (nonatomic, assign) BOOL videoAutoPlayOnWWAN;
/**
* 自动播放时,是否静音。默认 YES。loadAd 前设置。
*/
@property (nonatomic, assign) BOOL videoMuted;
/**
* 视频详情页播放时是否静音。默认NO。loadAd 前设置。
*/
@property (nonatomic, assign) BOOL detailPageVideoMuted;
/**
请求视频的时长下限,视频时长有效值范围为[5,60]。
以下两种情况会使用系统默认的最小值设置,1:不设置 2:minVideoDuration大于maxVideoDuration
*/
@property (nonatomic) NSInteger minVideoDuration;
/**
请求视频的时长上限,视频时长有效值范围为[5,60]。
*/
@property (nonatomic) NSInteger maxVideoDuration;
@property (nonatomic, readonly) NSString *placementId;
/**
* 构造方法
* 详解:placementId - 广告位 ID
* adSize - 广告展示的宽高
*/
- (instancetype)initWithPlacementId:(NSString *)placementId adSize:(CGSize)size;
/**
* 构造方法
* 详解:appId - 媒体 ID
* placementId - 广告位 ID
* adSize - 广告展示的宽高
*/
- (instancetype)initWithAppId:(NSString *)appId placementId:(NSString *)placementId adSize:(CGSize)size GDT_DEPRECATED_MSG_ATTRIBUTE("接口即将废弃,请使用 initWithPlacementId:adSize:");
- (void)loadAd:(NSInteger)count;
/**
返回广告平台名称
@return 当使用流量分配功能时,用于区分广告平台;未使用时为空字符串
*/
- (NSString *)adNetworkName;
@end
//
// GDTNativeExpressAdView.h
// GDTMobApp
//
// Created by michaelxing on 2017/4/14.
// Copyright © 2017年 Tencent. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface GDTNativeExpressAdView : UIView
/**
* 是否渲染完毕
*/
@property (nonatomic, assign, readonly) BOOL isReady;
/**
* 是否是视频模板广告
*/
@property (nonatomic, assign, readonly) BOOL isVideoAd;
/*
* viewControllerForPresentingModalView
* 详解:[必选]开发者需传入用来弹出目标页的ViewController,一般为当前ViewController
*/
@property (nonatomic, weak) UIViewController *controller;
/**
*[必选]
*原生模板广告渲染
*/
- (void)render;
/**
* 视频模板广告时长,单位 ms
*/
- (CGFloat)videoDuration;
/**
* 视频模板广告已播放时长,单位 ms
*/
- (CGFloat)videoPlayTime;
/**
返回广告的eCPM,单位:分
@return 成功返回一个大于等于0的值,-1表示无权限或后台出现异常
*/
- (NSInteger)eCPM;
/**
返回广告的eCPM等级
@return 成功返回一个包含数字的string,@""或nil表示无权限或后台异常
*/
- (NSString *)eCPMLevel;
@end
//
// GDTNativeExpressProAdManager.h
// GDTMobApp
//
// Created by royqpwang on 2020/4/28.
// Copyright © 2020 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "GDTAdParams.h"
NS_ASSUME_NONNULL_BEGIN
@class GDTNativeExpressProAdManager;
@class GDTNativeExpressProAdView;
@protocol GDTNativeExpressProAdManagerDelegate <NSObject>
@optional
/**
* 拉取原生模板2.0广告成功
*/
- (void)gdt_nativeExpressProAdSuccessToLoad:(GDTNativeExpressProAdManager *)adManager views:(NSArray<__kindof GDTNativeExpressProAdView *> *)views;
/**
* 拉取原生模板2.0广告失败
*/
- (void)gdt_nativeExpressProAdFailToLoad:(GDTNativeExpressProAdManager *)adManager error:(NSError *)error;
@end
@interface GDTNativeExpressProAdManager : NSObject
/**
* 委托对象
*/
@property (nonatomic, weak) id<GDTNativeExpressProAdManagerDelegate> delegate;
@property (nonatomic, readonly) NSString *placementId;
@property (nonatomic, strong, readonly) GDTAdParams *adParams;
/**
* 构造方法
* 详解:placementId - 广告位 ID
* adSize - 广告参数
*/
- (instancetype)initWithPlacementId:(NSString *)placementId adPrams:(GDTAdParams *)adParams;
- (void)loadAd:(NSInteger)count;
@end
NS_ASSUME_NONNULL_END
//
// GDTNativeExpressProAdView.h
// GDTMobApp
//
// Created by royqpwang on 2020/4/28.
// Copyright © 2020 Tencent. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GDTAdParams.h"
#import "GDTSDKDefines.h"
NS_ASSUME_NONNULL_BEGIN
@class GDTNativeExpressProAdView;
@protocol GDTNativeExpressProAdViewDelegate <NSObject>
@optional
/**
* 原生模板2.0广告渲染成功, 此时的 nativeExpressAdView.size.height 根据 size.width 完成了动态更新。
*/
- (void)gdt_NativeExpressProAdViewRenderSuccess:(GDTNativeExpressProAdView *)nativeExpressProAdView;
/**
* 原生模板2.0广告渲染失败
*/
- (void)gdt_NativeExpressProAdViewRenderFail:(GDTNativeExpressProAdView *)nativeExpressProAdView;
/**
* 原生模板2.0广告曝光回调
*/
- (void)gdt_NativeExpressProAdViewExposure:(GDTNativeExpressProAdView *)nativeExpressProAdView;
/**
* 原生模板2.0广告点击回调
*/
- (void)gdt_NativeExpressProAdViewClicked:(GDTNativeExpressProAdView *)nativeExpressProAdView;
/**
* 原生模板2.0广告被关闭
*/
- (void)gdt_NativeExpressProAdViewClosed:(GDTNativeExpressProAdView *)nativeExpressProAdView;
/**
* 点击原生模板2.0广告以后即将弹出全屏广告页
*/
- (void)gdt_NativeExpressProAdViewWillPresentScreen:(GDTNativeExpressProAdView *)nativeExpressProAdView;
/**
* 点击原生模板2.0广告以后弹出全屏广告页
*/
- (void)gdt_NativeExpressProAdViewDidPresentScreen:(GDTNativeExpressProAdView *)nativeExpressProAdView;
/**
* 全屏广告页将要关闭
*/
- (void)gdt_NativeExpressProAdViewWillDissmissScreen:(GDTNativeExpressProAdView *)nativeExpressProAdView;
/**
* 全屏广告页将要关闭
*/
- (void)gdt_NativeExpressProAdViewDidDissmissScreen:(GDTNativeExpressProAdView *)nativeExpressProAdView;
/**
* 详解:当点击应用下载或者广告调用系统程序打开时调用
*/
- (void)gdt_NativeExpressProAdViewApplicationWillEnterBackground:(GDTNativeExpressProAdView *)nativeExpressProAdView;
/**
* 原生模板视频广告 player 播放状态更新回调
*/
- (void)gdt_NativeExpressProAdView:(GDTNativeExpressProAdView *)nativeExpressProAdView playerStatusChanged:(GDTMediaPlayerStatus)status;
@end
@interface GDTNativeExpressProAdView : UIView
@property (nonatomic, weak) id <GDTNativeExpressProAdViewDelegate> delegate;
/**
* 是否渲染完毕
*/
@property (nonatomic, assign, readonly) BOOL isReady;
/**
* 是否是视频模板广告
*/
@property (nonatomic, assign, readonly) BOOL isVideoAd;
/*
* viewControllerForPresentingModalView
* 详解:[必选]开发者需传入用来弹出目标页的ViewController,一般为当前ViewController
*/
@property (nonatomic, weak) UIViewController *controller;
/**
*[必选]
*原生模板2.0广告渲染
*/
- (void)render;
/**
* 视频模板广告时长,单位 ms
*/
- (CGFloat)videoDuration;
/**
* 视频模板广告已播放时长,单位 ms
*/
- (CGFloat)videoPlayTime;
/**
返回广告的eCPM,单位:分
@return 成功返回一个大于等于0的值,-1表示无权限或后台出现异常
*/
- (NSInteger)eCPM;
/**
返回广告的eCPM等级
@return 成功返回一个包含数字的string,@""或nil表示无权限或后台异常
*/
- (NSString *)eCPMLevel;
@end
NS_ASSUME_NONNULL_END
//
// GDTRewardVideoAd.h
// GDTMobSDK
//
// Created by royqpwang on 2018/9/1.
// Copyright © 2018年 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "GDTSDKDefines.h"
#import "GDTLoadAdParams.h"
NS_ASSUME_NONNULL_BEGIN
@protocol GDTRewardedVideoAdDelegate;
@interface GDTRewardVideoAd : NSObject
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
@property (nonatomic) BOOL videoMuted;
@property (nonatomic, assign, readonly) NSInteger expiredTimestamp;
@property (nonatomic, weak) id <GDTRewardedVideoAdDelegate> delegate;
@property (nonatomic, readonly) NSString *placementId;
@property (nonatomic, strong) GDTLoadAdParams *loadAdParams;
/**
构造方法
@param placementId - 广告位 ID
@return GDTRewardVideoAd 实例
*/
- (instancetype)initWithPlacementId:(NSString *)placementId;
/**
构造方法
@param appId - 媒体 ID
@param placementId - 广告位 ID
@return GDTRewardVideoAd 实例
*/
- (instancetype)initWithAppId:(NSString *)appId placementId:(NSString *)placementId GDT_DEPRECATED_MSG_ATTRIBUTE("接口即将废弃,请使用 initWithPlacementId:");
/**
加载广告方法 支持 iOS8.1 及以上系统
*/
- (void)loadAd;
/**
展示广告方法
@param rootViewController 用于 present 激励视频 VC
@return 是否展示成功
*/
- (BOOL)showAdFromRootViewController:(UIViewController *)rootViewController;
/**
返回广告的eCPM,单位:分
@return 成功返回一个大于等于0的值,-1表示无权限或后台出现异常
*/
- (NSInteger)eCPM;
/**
返回广告的eCPM等级
@return 成功返回一个包含数字的string,@""或nil表示无权限或后台异常
*/
- (NSString *)eCPMLevel;
/**
返回广告平台名称
@return 当使用激励视频聚合功能时,用于区分广告平台
*/
- (NSString *)adNetworkName;
/**
* 当广告类型为 GDTRewardAdTypeVideo时,返回视频时长,单位 ms,当广告类型为GDTRewardAdTypePage时,返回0
*/
- (CGFloat)videoDuration;
/**
* 激励广告的类型,需在gdt_rewardVideoAdDidLoad回调后调用
*/
- (GDTRewardAdType)rewardAdType;
@end
@protocol GDTRewardedVideoAdDelegate <NSObject>
@optional
/**
广告数据加载成功回调
@param rewardedVideoAd GDTRewardVideoAd 实例
*/
- (void)gdt_rewardVideoAdDidLoad:(GDTRewardVideoAd *)rewardedVideoAd;
/**
视频数据下载成功回调,已经下载过的视频会直接回调
@param rewardedVideoAd GDTRewardVideoAd 实例
*/
- (void)gdt_rewardVideoAdVideoDidLoad:(GDTRewardVideoAd *)rewardedVideoAd;
/**
视频播放页即将展示回调
@param rewardedVideoAd GDTRewardVideoAd 实例
*/
- (void)gdt_rewardVideoAdWillVisible:(GDTRewardVideoAd *)rewardedVideoAd;
/**
视频广告曝光回调
@param rewardedVideoAd GDTRewardVideoAd 实例
*/
- (void)gdt_rewardVideoAdDidExposed:(GDTRewardVideoAd *)rewardedVideoAd;
/**
视频播放页关闭回调
@param rewardedVideoAd GDTRewardVideoAd 实例
*/
- (void)gdt_rewardVideoAdDidClose:(GDTRewardVideoAd *)rewardedVideoAd;
/**
视频广告信息点击回调
@param rewardedVideoAd GDTRewardVideoAd 实例
*/
- (void)gdt_rewardVideoAdDidClicked:(GDTRewardVideoAd *)rewardedVideoAd;
/**
视频广告各种错误信息回调
@param rewardedVideoAd GDTRewardVideoAd 实例
@param error 具体错误信息
*/
- (void)gdt_rewardVideoAd:(GDTRewardVideoAd *)rewardedVideoAd didFailWithError:(NSError *)error;
/**
视频广告播放达到激励条件回调
@param rewardedVideoAd GDTRewardVideoAd 实例
*/
- (void)gdt_rewardVideoAdDidRewardEffective:(GDTRewardVideoAd *)rewardedVideoAd;
/**
视频广告视频播放完成
@param rewardedVideoAd GDTRewardVideoAd 实例
*/
- (void)gdt_rewardVideoAdDidPlayFinish:(GDTRewardVideoAd *)rewardedVideoAd;
@end
NS_ASSUME_NONNULL_END
//
// GDTRewardVideoAdNetworkAdapterProtocol.h
// GDTMobApp
//
// Created by royqpwang on 2019/6/19.
// Copyright © 2019 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "GDTBaseAdNetworkAdapterProtocol.h"
@protocol GDTRewardVideoAdNetworkConnectorProtocol;
NS_ASSUME_NONNULL_BEGIN
@protocol GDTRewardVideoAdNetworkAdapterProtocol <GDTBaseAdNetworkAdapterProtocol>
- (void)loadAd;
- (BOOL)showAdFromRootViewController:(UIViewController *)viewController;
- (BOOL)isAdValid;
- (NSInteger)expiredTimestamp;
@optional
@property (nonatomic) BOOL videoMuted;
@end
NS_ASSUME_NONNULL_END
//
// GDTRewardVideoAdNetworkConnectorProtocol.h
// GDTMobApp
//
// Created by royqpwang on 2019/6/19.
// Copyright © 2019 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol GDTRewardVideoAdNetworkAdapterProtocol;
@protocol GDTRewardVideoAdNetworkConnectorProtocol <NSObject>
- (void)adapter_rewardVideoAdDidLoad:(id<GDTRewardVideoAdNetworkAdapterProtocol>)adapter;
/**
视频数据下载成功回调,已经下载过的视频会直接回调
@param adapter 实例
*/
- (void)adapter_rewardVideoAdVideoDidLoad:(id<GDTRewardVideoAdNetworkAdapterProtocol>)adapter;
/**
视频播放页即将展示回调
@param adapter 实例
*/
- (void)adapter_rewardVideoAdWillVisible:(id<GDTRewardVideoAdNetworkAdapterProtocol>)adapter;
/**
视频广告曝光回调
@param adapter 实例
*/
- (void)adapter_rewardVideoAdDidExposed:(id<GDTRewardVideoAdNetworkAdapterProtocol>)adapter;
/**
视频播放页关闭回调
@param adapter 实例
*/
- (void)adapter_rewardVideoAdDidClose:(id<GDTRewardVideoAdNetworkAdapterProtocol>)adapter;
/**
视频广告信息点击回调
@param adapter 实例
*/
- (void)adapter_rewardVideoAdDidClicked:(id<GDTRewardVideoAdNetworkAdapterProtocol>)adapter;
/**
视频广告各种错误信息回调
@param adapter 实例
@param error 具体错误信息
*/
- (void)adapter_rewardVideoAd:(id<GDTRewardVideoAdNetworkAdapterProtocol>)adapter didFailWithError:(NSError *)error;
/**
视频广告播放达到激励条件回调
@param adapter 实例
*/
- (void)adapter_rewardVideoAdDidRewardEffective:(id<GDTRewardVideoAdNetworkAdapterProtocol>)adapter;
- (void)adapter_rewardVideoAdDidPlayFinish:(id<GDTRewardVideoAdNetworkAdapterProtocol>)adapter;
@end
//
// GDTSDKConfig.h
// GDTMobApp
//
// Created by GaoChao on 14/8/25.
// Copyright (c) 2014年 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "GDTSDKDefines.h"
#import "GDTAdTestSetting.h"
@interface GDTSDKConfig : NSObject
/**
SDK 注册接口,请在 app 初始化时调用。
@param appId - 媒体ID
@return 注册是否成功。
*/
+ (BOOL)registerAppId:(NSString *)appId;
/**
* 提供给聚合平台用来设定SDK 流量分类
*/
+ (void)setSdkSrc:(NSString *)sdkSrc;
/**
* 查看SDK流量来源
*/
+ (NSString *)sdkSrc;
/**
* 获取 SDK 版本
*/
+ (NSString *)sdkVersion;
+ (void)enableGPS:(BOOL)enabled;
/**
* 设置流量渠道号
渠道号信息主要用来协助平台提升流量变现效果及您的收益,请如实填写,若渠道号无法满足您的诉求请联系平台负责商务
渠道号映射关系为:
1:百度
2:头条
3:广点通
4:搜狗
5:其他网盟
6:oppo
7:vivo
8:华为
9:应用宝
10:小米
11:金立
12:百度手机助手
13:魅族
14:AppStore
999:其他
*/
+ (void)setChannel:(NSInteger)channel;
+ (void)setSDKType:(NSInteger)type;
/**
在播放音频时是否使用SDK内部对AVAudioSession设置的category及options,默认使用,若不使用,SDK内部不做任何处理,由调用方在展示广告时自行设置;
SDK设置的category为AVAudioSessionCategoryAmbient,options为AVAudioSessionCategoryOptionDuckOthers
*/
+ (void)enableDefaultAudioSessionSetting:(BOOL)enabled;
+ (GDTAdTestSetting *)debugSetting;
/**
设置开发阶段调试相关的配置
*/
+ (void)setDebugSetting:(GDTAdTestSetting *)debugSetting;
+ (void)forbiddenIDFA:(BOOL)forbiddened;
@end
//
// GDTSDKDefines.h
// GDTMobApp
//
// Created by royqpwang on 2017/11/6.
// Copyright © 2017年 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#if defined(__has_attribute)
#if __has_attribute(deprecated)
#define GDT_DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
#define GDT_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
#else
#define GDT_DEPRECATED_MSG_ATTRIBUTE(s)
#define GDT_DEPRECATED_ATTRIBUTE
#endif
#else
#define GDT_DEPRECATED_MSG_ATTRIBUTE(s)
#define GDT_DEPRECATED_ATTRIBUTE
#endif
#define GDTScreenHeight ([UIScreen mainScreen].bounds.size.height)
#define GDTScreenWidth ([UIScreen mainScreen].bounds.size.width)
/**
* 视频播放器状态
*
* 播放器只可能处于以下状态中的一种
*
*/
typedef NS_ENUM(NSUInteger, GDTMediaPlayerStatus) {
GDTMediaPlayerStatusInitial = 0, // 初始状态
GDTMediaPlayerStatusLoading = 1, // 加载中
GDTMediaPlayerStatusStarted = 2, // 开始播放
GDTMediaPlayerStatusPaused = 3, // 用户行为导致暂停
GDTMediaPlayerStatusError = 4, // 播放出错
GDTMediaPlayerStatusStoped = 5, // 播放停止
};
typedef enum GDTSDKLoginType {
GDTSDKLoginTypeUnknow = 0,
GDTSDKLoginTypeWeiXin = 1, //微信账号
GDTSDKLoginTypeQQ = 2, //QQ账号
} GDTSDKLoginType;
typedef NS_ENUM(NSUInteger, GDTVideoPlayPolicy) {
GDTVideoPlayPolicyUnknow = 0, // 默认值,未设置
GDTVideoPlayPolicyAuto = 1, // 用户角度看起来是自动播放
GDTVideoPlayPolicyManual = 2 // 用户角度看起来是手动播放或点击后播放
};
typedef NS_ENUM(NSUInteger, GDTVideoRenderType) {
GDTVideoRenderTypeUnknow = 0,
GDTVideoRenderTypeSDK = 1,
GDTVideoRenderTypeDeveloper = 2
};
typedef NS_ENUM (NSUInteger, GDTRewardAdType) {
GDTRewardAdTypeVideo = 0,//激励视频
GDTRewardAdTypePage = 1 //激励浏览
};
static inline BOOL isIPhoneXSeries() {
if (@available(iOS 11.0, *)) {
UIWindow *mainWindow = [[[UIApplication sharedApplication] delegate] window];
if (mainWindow.safeAreaInsets.bottom > 0.0) {
return YES;
}
}
return NO;
}
//
// GDTSplashAd.h
// GDTMobApp
//
// 广点通开屏广告,目前只支持iPhone设备上展示垂直方向的开屏广告
// Created by GaoChao on 15/8/20.
// Copyright © 2015年 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "GDTSDKDefines.h"
@class GDTSplashAd;
@protocol GDTSplashAdDelegate <NSObject>
@optional
/**
* 开屏广告成功展示
*/
- (void)splashAdSuccessPresentScreen:(GDTSplashAd *)splashAd;
/**
* 开屏广告素材加载成功
*/
- (void)splashAdDidLoad:(GDTSplashAd *)splashAd;
/**
* 开屏广告展示失败
*/
- (void)splashAdFailToPresent:(GDTSplashAd *)splashAd withError:(NSError *)error;
/**
* 应用进入后台时回调
* 详解: 当点击下载应用时会调用系统程序打开,应用切换到后台
*/
- (void)splashAdApplicationWillEnterBackground:(GDTSplashAd *)splashAd;
/**
* 开屏广告曝光回调
*/
- (void)splashAdExposured:(GDTSplashAd *)splashAd;
/**
* 开屏广告点击回调
*/
- (void)splashAdClicked:(GDTSplashAd *)splashAd;
/**
* 开屏广告将要关闭回调
*/
- (void)splashAdWillClosed:(GDTSplashAd *)splashAd;
/**
* 开屏广告关闭回调
*/
- (void)splashAdClosed:(GDTSplashAd *)splashAd;
/**
* 开屏广告点击以后即将弹出全屏广告页
*/
- (void)splashAdWillPresentFullScreenModal:(GDTSplashAd *)splashAd;
/**
* 开屏广告点击以后弹出全屏广告页
*/
- (void)splashAdDidPresentFullScreenModal:(GDTSplashAd *)splashAd;
/**
* 点击以后全屏广告页将要关闭
*/
- (void)splashAdWillDismissFullScreenModal:(GDTSplashAd *)splashAd;
/**
* 点击以后全屏广告页已经关闭
*/
- (void)splashAdDidDismissFullScreenModal:(GDTSplashAd *)splashAd;
/**
* 开屏广告剩余时间回调
*/
- (void)splashAdLifeTime:(NSUInteger)time;
@end
@interface GDTSplashAd : NSObject
/**
* 委托对象
*/
@property (nonatomic, weak) id<GDTSplashAdDelegate> delegate;
/**
* 拉取广告超时时间,默认为3秒
* 详解:拉取广告超时时间,开发者调用loadAd方法以后会立即展示backgroundImage,然后在该超时时间内,如果广告拉
* 取成功,则立马展示开屏广告,否则放弃此次广告展示机会。
*/
@property (nonatomic, assign) CGFloat fetchDelay;
/**
* 开屏广告的背景图片
* 可以设置背景图片作为开屏加载时的默认背景
*/
@property (nonatomic, strong) UIImage *backgroundImage;
/**
* 开屏广告的背景色
* 可以设置开屏图片来作为开屏加载时的默认图片
*/
@property (nonatomic, copy) UIColor *backgroundColor;
/**
* 跳过按钮的位置
*/
@property (nonatomic, assign) CGPoint skipButtonCenter;
/**
返回广告平台名称
@return 当使用流量分配功能时,用于区分广告平台;未使用时为空字符串
*/
- (NSString *)adNetworkName;
/**
返回广告的eCPM等级
@return 成功返回一个包含数字的string,@""或nil表示无权限或后台异常
*/
- (NSString *)eCPMLevel;
/**
* 构造方法
* 详解:placementId - 广告位 ID
*/
- (instancetype)initWithPlacementId:(NSString *)placementId;
/**
预加载闪屏广告接口
@param placementId 广告位ID
*/
+ (void)preloadSplashOrderWithPlacementId:(NSString *)placementId;
#pragma mark - Parallel method
/**
* 返回广告是否可展示
* 对于并行请求,在调用showAdInWindow前时需判断下
* @return 当广告已经加载完成且未曝光时,为YES,否则为NO
*/
- (BOOL)isAdValid;
/**
* 发起拉取广告请求,只拉取不展示
* 详解:广告素材及广告图片拉取成功后会回调splashAdDidLoad方法,当拉取失败时会回调splashAdFailToPresent方法
*/
- (void)loadAd;
/**
* 展示广告,调用此方法前需调用isAdValid方法判断广告素材是否有效
* 详解:广告展示成功时会回调splashAdSuccessPresentScreen方法,展示失败时会回调splashAdFailToPresent方法
*/
- (void)showAdInWindow:(UIWindow *)window withBottomView:(UIView *)bottomView skipView:(UIView *)skipView;
/**
* 构造方法
* 详解:appId - 媒体 ID
* placementId - 广告位 ID
*/
- (instancetype)initWithAppId:(NSString *)appId placementId:(NSString *)placementId GDT_DEPRECATED_MSG_ATTRIBUTE("接口即将废弃,请使用 initWithPlacementId:");
/**
* 广告发起请求并展示在Window中
* 详解:[可选]发起拉取广告请求,并将获取的广告以全屏形式展示在传入的Window参数中
* 提示: Splash广告只支持竖屏
* @param window 展示全屏开屏的容器
*/
- (void)loadAdAndShowInWindow:(UIWindow *)window GDT_DEPRECATED_MSG_ATTRIBUTE("接口即将废弃,请分别使用loadAd 和 showAdInWindow:接口");
/**
* 广告发起请求并展示在Window中, 同时在屏幕底部设置应用自身的Logo页面或是自定义View
* 详解:[可选]发起拉取广告请求,并将获取的广告以半屏形式展示在传入的Window的上半部,剩余部分展示传入的bottomView
* 请注意1.bottomView需设置好宽高,所占的空间不能过大,并保证高度不超过屏幕高度的 25%。2.Splash广告只支持竖屏
* @param window 展示开屏的容器
* bottomView 自定义底部View,可以在此View中设置应用Logo
*/
- (void)loadAdAndShowInWindow:(UIWindow *)window withBottomView:(UIView *)bottomView GDT_DEPRECATED_MSG_ATTRIBUTE("接口即将废弃,请分别使用loadAd 和 showAdInWindow:接口");
/**
* 广告发起请求并展示在Window中, 同时在屏幕底部设置应用自身的Logo页面或是自定义View,skipView是自定义的“跳过”样式
* 详解:[可选]发起拉取广告请求,并将获取的广告以半屏形式展示在传入的Window的上半部,剩余部分展示传入的bottomView
* 请注意1.bottomView需设置好宽高,所占的空间不能过大,并保证高度不超过屏幕高度的 25%。2.Splash广告只支持竖屏
* skipView
* @param window 展示开屏的容器
* bottomView 自定义底部View,可以在此View中设置应用Logo
skipView 自定义”跳过“View.
*/
- (void)loadAdAndShowInWindow:(UIWindow *)window withBottomView:(UIView *)bottomView skipView:(UIView *)skipView GDT_DEPRECATED_MSG_ATTRIBUTE("接口即将废弃,请分别使用loadAd 和 showAdInWindow:接口");
@end
//
// GDTUnifiedBannerView.h
// GDTMobSDK
//
// Created by nimomeng on 2019/3/1.
// Copyright © 2019 Tencent. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GDTLoadAdParams.h"
NS_ASSUME_NONNULL_BEGIN
@class GDTUnifiedBannerView;
@protocol GDTUnifiedBannerViewDelegate <NSObject>
@optional
/**
* 请求广告条数据成功后调用
* 当接收服务器返回的广告数据成功后调用该函数
*/
- (void)unifiedBannerViewDidLoad:(GDTUnifiedBannerView *)unifiedBannerView;
/**
* 请求广告条数据失败后调用
* 当接收服务器返回的广告数据失败后调用该函数
*/
- (void)unifiedBannerViewFailedToLoad:(GDTUnifiedBannerView *)unifiedBannerView error:(NSError *)error;
/**
* banner2.0曝光回调
*/
- (void)unifiedBannerViewWillExpose:(GDTUnifiedBannerView *)unifiedBannerView;
/**
* banner2.0点击回调
*/
- (void)unifiedBannerViewClicked:(GDTUnifiedBannerView *)unifiedBannerView;
/**
* banner2.0广告点击以后即将弹出全屏广告页
*/
- (void)unifiedBannerViewWillPresentFullScreenModal:(GDTUnifiedBannerView *)unifiedBannerView;
/**
* banner2.0广告点击以后弹出全屏广告页完毕
*/
- (void)unifiedBannerViewDidPresentFullScreenModal:(GDTUnifiedBannerView *)unifiedBannerView;
/**
* 全屏广告页即将被关闭
*/
- (void)unifiedBannerViewWillDismissFullScreenModal:(GDTUnifiedBannerView *)unifiedBannerView;
/**
* 全屏广告页已经被关闭
*/
- (void)unifiedBannerViewDidDismissFullScreenModal:(GDTUnifiedBannerView *)unifiedBannerView;
/**
* 当点击应用下载或者广告调用系统程序打开
*/
- (void)unifiedBannerViewWillLeaveApplication:(GDTUnifiedBannerView *)unifiedBannerView;
/**
* banner2.0被用户关闭时调用
*/
- (void)unifiedBannerViewWillClose:(GDTUnifiedBannerView *)unifiedBannerView;
@end
@interface GDTUnifiedBannerView : UIView
/**
* 委托 [可选]
*/
@property (nonatomic, weak) id<GDTUnifiedBannerViewDelegate> delegate;
/**
* Banner展现和轮播时的动画效果开关,默认打开
*/
@property (nonatomic) BOOL animated;
/**
* 广告刷新间隔,范围 [30, 120] 秒,默认值 30 秒。设 0 则不刷新。 [可选]
*/
@property (nonatomic) int autoSwitchInterval;
/**
* QQ小游戏SDK字段透传
*/
@property (nonatomic, strong) GDTLoadAdParams *loadAdParams;
/**
* 构造方法
* 详解:placementId - 广告位 ID
* viewController - 视图控制器
*/
- (instancetype)initWithPlacementId:(NSString *)placementId
viewController:(UIViewController *)viewController;
/**
* 构造方法
* 详解:frame - banner 展示的位置和大小
* placementId - 广告位 ID
* viewController - 视图控制器
*/
- (instancetype)initWithFrame:(CGRect)frame
placementId:(NSString *)placementId
viewController:(UIViewController *)viewController;
/**
* 拉取并展示广告
*/
- (void)loadAdAndShow;
@end
NS_ASSUME_NONNULL_END
//
// GDTUnifiedInterstitialAd.h
// GDTMobApp
//
// Created by nimomeng on 2019/3/4.
// Copyright © 2019 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "GDTSDKDefines.h"
NS_ASSUME_NONNULL_BEGIN
@class GDTUnifiedInterstitialAd;
@protocol GDTUnifiedInterstitialAdDelegate <NSObject>
@optional
/**
* 插屏2.0广告预加载成功回调
* 当接收服务器返回的广告数据成功且预加载后调用该函数
*/
- (void)unifiedInterstitialSuccessToLoadAd:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 插屏2.0广告预加载失败回调
* 当接收服务器返回的广告数据失败后调用该函数
*/
- (void)unifiedInterstitialFailToLoadAd:(GDTUnifiedInterstitialAd *)unifiedInterstitial error:(NSError *)error;
/**
* 插屏2.0广告将要展示回调
* 插屏2.0广告即将展示回调该函数
*/
- (void)unifiedInterstitialWillPresentScreen:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 插屏2.0广告视图展示成功回调
* 插屏2.0广告展示成功回调该函数
*/
- (void)unifiedInterstitialDidPresentScreen:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 插屏2.0广告视图展示失败回调
* 插屏2.0广告展示失败回调该函数
*/
- (void)unifiedInterstitialFailToPresent:(GDTUnifiedInterstitialAd *)unifiedInterstitial error:(NSError *)error;
/**
* 插屏2.0广告展示结束回调
* 插屏2.0广告展示结束回调该函数
*/
- (void)unifiedInterstitialDidDismissScreen:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 当点击下载应用时会调用系统程序打开其它App或者Appstore时回调
*/
- (void)unifiedInterstitialWillLeaveApplication:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 插屏2.0广告曝光回调
*/
- (void)unifiedInterstitialWillExposure:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 插屏2.0广告点击回调
*/
- (void)unifiedInterstitialClicked:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 点击插屏2.0广告以后即将弹出全屏广告页
*/
- (void)unifiedInterstitialAdWillPresentFullScreenModal:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 点击插屏2.0广告以后弹出全屏广告页
*/
- (void)unifiedInterstitialAdDidPresentFullScreenModal:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 全屏广告页将要关闭
*/
- (void)unifiedInterstitialAdWillDismissFullScreenModal:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 全屏广告页被关闭
*/
- (void)unifiedInterstitialAdDidDismissFullScreenModal:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 插屏2.0视频广告 player 播放状态更新回调
*/
- (void)unifiedInterstitialAd:(GDTUnifiedInterstitialAd *)unifiedInterstitial playerStatusChanged:(GDTMediaPlayerStatus)status;
/**
* 插屏2.0视频广告详情页 WillPresent 回调
*/
- (void)unifiedInterstitialAdViewWillPresentVideoVC:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 插屏2.0视频广告详情页 DidPresent 回调
*/
- (void)unifiedInterstitialAdViewDidPresentVideoVC:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 插屏2.0视频广告详情页 WillDismiss 回调
*/
- (void)unifiedInterstitialAdViewWillDismissVideoVC:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
/**
* 插屏2.0视频广告详情页 DidDismiss 回调
*/
- (void)unifiedInterstitialAdViewDidDismissVideoVC:(GDTUnifiedInterstitialAd *)unifiedInterstitial;
@end
@interface GDTUnifiedInterstitialAd : NSObject
/**
* 插屏2.0广告预加载是否完成
*/
@property (nonatomic, readonly) BOOL isAdValid;
/**
* 委托对象
*/
@property (nonatomic, weak) id<GDTUnifiedInterstitialAdDelegate> delegate;
@property (nonatomic, readonly) NSString *placementId;
/**
* 构造方法
* 详解:placementId - 广告位 ID
*/
- (instancetype)initWithPlacementId:(NSString *)placementId;
/**
* 构造方法
* 详解:appId - 媒体 ID
* placementId - 广告位 ID
*/
- (instancetype)initWithAppId:(NSString *)appId placementId:(NSString *)placementId GDT_DEPRECATED_MSG_ATTRIBUTE("接口即将废弃,请使用 initWithPlacementId:");
/**
* 广告发起请求方法
* 详解:[必选]发起拉取广告请求
*/
- (void)loadAd;
/**
* 插屏全屏视频广告发起请求方法
* 详解:[必选]发起拉取广告请求
*/
- (void)loadFullScreenAd;
/**
* 广告展示方法
* 详解:[必选]发起展示广告请求, 必须传入用于显示插播广告的UIViewController
*/
- (void)presentAdFromRootViewController:(UIViewController *)rootViewController;
/**
* 插屏视频全屏广告展示方法
* 详解:[必选]发起展示广告请求, 必须传入用于显示插播广告的UIViewController
*/
- (void)presentFullScreenAdFromRootViewController:(UIViewController *)rootViewController;
/**
返回广告的eCPM,单位:分
@return 成功返回一个大于等于0的值,-1表示无权限或后台出现异常
*/
- (NSInteger)eCPM;
/**
返回广告的eCPM等级
@return 成功返回一个包含数字的string,@""或nil表示无权限或后台异常
*/
- (NSString *)eCPMLevel;
/**
* 非 WiFi 网络,是否自动播放。默认 NO。loadAd 前设置。
*/
@property (nonatomic, assign) BOOL videoAutoPlayOnWWAN;
/**
* 自动播放时,是否静音。默认 YES。loadAd 前设置。
*/
@property (nonatomic, assign) BOOL videoMuted;
/**
* 视频详情页播放时是否静音。默认NO。loadAd 前设置。
*/
@property (nonatomic, assign) BOOL detailPageVideoMuted;
/**
请求视频的时长下限,视频时长有效值范围为[5,60]。
以下两种情况会使用系统默认的最小值设置,1:不设置 2:minVideoDuration大于maxVideoDuration
*/
@property (nonatomic) NSInteger minVideoDuration;
/**
请求视频的时长上限,视频时长有效值范围为[5,60]。
*/
@property (nonatomic) NSInteger maxVideoDuration;
/**
* 是否是视频插屏2.0广告
*/
@property (nonatomic, assign, readonly) BOOL isVideoAd;
/**
* 视频插屏2.0广告时长,单位 ms
*/
- (CGFloat)videoDuration;
/**
* 视频插屏广告已播放时长,单位 ms
*/
- (CGFloat)videoPlayTime;
/**
返回广告平台名称
@return 当使用流量分配功能时,用于区分广告平台;未使用时为空字符串
*/
- (NSString *)adNetworkName;
@end
NS_ASSUME_NONNULL_END
//
// GDTUnifiedNativeAd.h
// GDTMobSDK
//
// Created by nimomeng on 2018/10/10.
// Copyright © 2018 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "GDTUnifiedNativeAdDataObject.h"
#import "GDTUnifiedNativeAdView.h"
NS_ASSUME_NONNULL_BEGIN
@protocol GDTUnifiedNativeAdDelegate <NSObject>
/**
广告数据回调
@param unifiedNativeAdDataObjects 广告数据数组
@param error 错误信息
*/
- (void)gdt_unifiedNativeAdLoaded:(NSArray<GDTUnifiedNativeAdDataObject *> * _Nullable)unifiedNativeAdDataObjects error:(NSError * _Nullable)error;
@end
@interface GDTUnifiedNativeAd : NSObject
@property (nonatomic, weak) id<GDTUnifiedNativeAdDelegate> delegate;
/**
请求视频的时长下限,视频时长有效值范围为[5,60]。
以下两种情况会使用系统默认的最小值设置,1:不设置 2:minVideoDuration大于maxVideoDuration
*/
@property (nonatomic) NSInteger minVideoDuration;
/**
请求视频的最大时长,视频时长有效值范围为[5,60]。
*/
@property (nonatomic) NSInteger maxVideoDuration;
/**
可选属性,设置本次拉取的视频广告从用户角度看到的视频播放策略。
“用户角度”特指用户看到的情况,并非SDK是否自动播放,与自动播放策略 GDTVideoAutoPlayPolicy 的取值并非一一对应
例如开发者设置了 GDTVideoAutoPlayPolicyNever 表示 SDK 不自动播放视频,但是开发者通过 GDTMediaView 的 play 方法播放视频,这在用户看来仍然是自动播放的。
准确的设置 GDTVideoPlayPolicy 有助于提高视频广告的eCPM值,如果广告位仅支持图文广告,则无需调用。
需要在 loadAd 前设置此属性。
*/
@property (nonatomic, assign) GDTVideoPlayPolicy videoPlayPolicy;
/**
可选属性,设置本次拉取的视频广告封面是由SDK渲染还是开发者自行渲染。
SDK 渲染,指视频广告 containerView 直接在 feed 流等场景展示,用户可以直接看到渲染的视频广告。Demo 工程中的 “视频Feed” 就是 SDK 渲染。
开发者自行渲染,指开发者获取到广告对象后,先用封面图字段在 feed 流中先渲染出一个封面图入口,用户点击封面图,再进入一个有 conainterView 的详细页,播放视频。Demo 工程中的 "竖版 Feed 视频" 就是开发者渲染的场景。
*/
@property (nonatomic, assign) GDTVideoRenderType videoRenderType;
/**
构造方法
@param placementId 广告位ID
@return GDTUnifiedNativeAd 实例
*/
- (instancetype)initWithPlacementId:(NSString *)placementId;
/**
构造方法
@param appId 媒体ID
@param placementId 广告位ID
@return GDTUnifiedNativeAd 实例
*/
- (instancetype)initWithAppId:(NSString *)appId placementId:(NSString *)placementId GDT_DEPRECATED_MSG_ATTRIBUTE("接口即将废弃,请使用 initWithPlacementId:");
/**
加载广告
*/
- (void)loadAd;
/**
加载广告
@param adCount 加载条数
*/
- (void)loadAdWithAdCount:(NSInteger)adCount;
/**
返回广告平台名称
@return 当使用流量分配功能时,用于区分广告平台;未使用时为空字符串
*/
- (NSString *)adNetworkName;
/**
* 当需要支持 VAST 广告时,需流量自行配置 adapter 的 vastClassName
*/
- (void)setVastClassName:(NSString *)vastClassName;
@end
NS_ASSUME_NONNULL_END
//
// GDTUnifiedNativeAdDataObject.h
// GDTMobSDK
//
// Created by nimomeng on 2018/10/10.
// Copyright © 2018 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "GDTVideoConfig.h"
typedef NS_ENUM(NSInteger, GDTVastAdEventType) {
GDTVastAdEventTypeUnknow,
GDTVastAdEventTypeLoaded,
GDTVastAdEventTypeStarted,
GDTVastAdEventTypeFirstQuartile,
GDTVastAdEventTypeMidPoint,
GDTVastAdEventTypeThirdQuartile,
GDTVastAdEventTypeComplete,
GDTVastAdEventTypeAllAdsComplete,
GDTVastAdEventTypeExposed,
GDTVastAdEventTypeClicked,
};
@interface GDTUnifiedNativeAdDataObject : NSObject
/**
广告标题
*/
@property (nonatomic, copy, readonly) NSString *title;
/**
广告描述
*/
@property (nonatomic, copy, readonly) NSString *desc;
/**
广告大图Url
*/
@property (nonatomic, copy, readonly) NSString *imageUrl;
/**
素材宽度,单图广告代表大图 imageUrl 宽度、多图广告代表小图 mediaUrlList 宽度
*/
@property (nonatomic, readonly) NSInteger imageWidth;
/**
素材高度,单图广告代表大图 imageUrl 高度、多图广告代表小图 mediaUrlList 高度
*/
@property (nonatomic, readonly) NSInteger imageHeight;
/**
应用类广告App 图标Url
*/
@property (nonatomic, copy, readonly) NSString *iconUrl;
/**
三小图广告的图片Url集合
*/
@property (nonatomic, copy, readonly) NSArray *mediaUrlList;
/**
应用类广告的星级(5星制度)
*/
@property (nonatomic, readonly) CGFloat appRating;
/**
应用类广告的价格
*/
@property (nonatomic, strong, readonly) NSNumber *appPrice;
/**
是否为应用类广告
*/
@property (nonatomic, readonly) BOOL isAppAd;
/**
是否为视频广告
*/
@property (nonatomic, readonly) BOOL isVideoAd;
/**
是否为三小图广告
*/
@property (nonatomic, readonly) BOOL isThreeImgsAd;
/**
返回广告的eCPM,单位:分
@return 成功返回一个大于等于0的值,-1表示无权限或后台出现异常
*/
@property (nonatomic, readonly) NSInteger eCPM;
/**
返回广告的eCPM等级
@return 成功返回一个包含数字的string,@""或nil表示无权限或后台异常
*/
@property (nonatomic, readonly) NSString *eCPMLevel;
/**
广告对应的CTA文案,自定义CTA视图时建议使用此字段
广告对应的callToAction文案,比如“立即预约”或“电话咨询”, 自定义callToAction视图时建议使用此字段
该字段在部分广告类型中可能为空
*/
@property (nonatomic, readonly) NSString *callToAction;
/**
返回广告是否可以跳过,用于做前贴片场景
@return YES 表示可跳过、NO 表示不可跳过
*/
@property (nonatomic, readonly) BOOL skippable;
/**
视频广告播放配置
*/
@property (nonatomic, strong) GDTVideoConfig *videoConfig;
/**
* 视频广告时长,单位 ms
*/
@property (nonatomic, readonly) CGFloat duration;
/**
* VAST Tag Url,可能为空。
*/
@property (nonatomic, copy, readonly) NSString *vastTagUrl;
/**
* VAST Content,可能为空。
*/
@property (nonatomic, copy, readonly) NSString *vastContent;
/**
* 是否为 VAST 广告
*/
@property (nonatomic, assign, readonly) BOOL isVastAd;
/**
判断两个自渲染2.0广告数据是否相等
@param dataObject 需要对比的自渲染2.0广告数据对象
@return YES or NO
*/
- (BOOL)equalsAdData:(GDTUnifiedNativeAdDataObject *)dataObject;
@end
//
// GDTUnifiedNativeAdView.h
// GDTMobSDK
//
// Created by nimomeng on 2018/10/10.
// Copyright © 2018 Tencent. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GDTLogoView.h"
#import "GDTMediaView.h"
#import "GDTUnifiedNativeAdDataObject.h"
#import "GDTSDKDefines.h"
@class GDTUnifiedNativeAdView;
//视频广告时长Key
extern NSString* const kGDTUnifiedNativeAdKeyVideoDuration;
@protocol GDTUnifiedNativeAdViewDelegate <NSObject>
@optional
/**
广告曝光回调
@param unifiedNativeAdView GDTUnifiedNativeAdView 实例
*/
- (void)gdt_unifiedNativeAdViewWillExpose:(GDTUnifiedNativeAdView *)unifiedNativeAdView;
/**
广告点击回调
@param unifiedNativeAdView GDTUnifiedNativeAdView 实例
*/
- (void)gdt_unifiedNativeAdViewDidClick:(GDTUnifiedNativeAdView *)unifiedNativeAdView;
/**
广告详情页关闭回调
@param unifiedNativeAdView GDTUnifiedNativeAdView 实例
*/
- (void)gdt_unifiedNativeAdDetailViewClosed:(GDTUnifiedNativeAdView *)unifiedNativeAdView;
/**
当点击应用下载或者广告调用系统程序打开时调用
@param unifiedNativeAdView GDTUnifiedNativeAdView 实例
*/
- (void)gdt_unifiedNativeAdViewApplicationWillEnterBackground:(GDTUnifiedNativeAdView *)unifiedNativeAdView;
/**
广告详情页面即将展示回调
@param unifiedNativeAdView GDTUnifiedNativeAdView 实例
*/
- (void)gdt_unifiedNativeAdDetailViewWillPresentScreen:(GDTUnifiedNativeAdView *)unifiedNativeAdView;
/**
视频广告播放状态更改回调
@param nativeExpressAdView GDTUnifiedNativeAdView 实例
@param status 视频广告播放状态
@param userInfo 视频广告信息
*/
- (void)gdt_unifiedNativeAdView:(GDTUnifiedNativeAdView *)unifiedNativeAdView playerStatusChanged:(GDTMediaPlayerStatus)status userInfo:(NSDictionary *)userInfo;
@end
@interface GDTUnifiedNativeAdView:UIView
/**
绑定的数据对象
*/
@property (nonatomic, strong, readonly) GDTUnifiedNativeAdDataObject *dataObject;
/**
视频广告的媒体View,绑定数据对象后自动生成,可自定义布局
*/
@property (nonatomic, strong, readonly) GDTMediaView *mediaView;
/**
腾讯广告 LogoView,自动生成,可自定义布局
*/
@property (nonatomic, strong, readonly) GDTLogoView *logoView;
/**
广告 View 时间回调对象
*/
@property (nonatomic, weak) id<GDTUnifiedNativeAdViewDelegate> delegate;
/*
* viewControllerForPresentingModalView
* 详解:开发者需传入用来弹出目标页的ViewController,一般为当前ViewController
*/
@property (nonatomic, weak) UIViewController *viewController;
/**
自渲染2.0视图注册方法
@param dataObject 数据对象,必传字段
@param clickableViews 可点击的视图数组,此数组内的广告元素才可以响应广告对应的点击事件
*/
- (void)registerDataObject:(GDTUnifiedNativeAdDataObject *)dataObject
clickableViews:(NSArray<UIView *> *)clickableViews;
/**
自渲染2.0视图注册方法
@param dataObject 数据对象,必传字段
@param clickableViews 可点击的视图数组,此数组内的广告元素才可以响应广告对应的点击事件
@param customClickableViews 可点击的视图数组,与clickableViews的区别是:在视频广告中当dataObject中的videoConfig的detailPageEnable为YES时,点击后直接进落地页而非视频详情页,除此条件外点击行为与clickableViews保持一致
*/
- (void)registerDataObject:(GDTUnifiedNativeAdDataObject *)dataObject
clickableViews:(NSArray<UIView *> *)clickableViews customClickableViews:(NSArray <UIView *> *)customClickableViews;
/**
注册可点击的callToAction视图的方法
建议开发者使用GDTUnifiedNativeAdDataObject中的callToAction字段来创建视图,并取代自定义的下载或打开等button,
调用此方法之前必须先调用registerDataObject:clickableViews
@param callToActionView CTA视图, 系统自动处理点击事件
*/
- (void)registerClickableCallToActionView:(UIView *)callToActionView;
/**
注销数据对象,在 tableView、collectionView 等场景需要复用 GDTUnifiedNativeAdView 时,
需要在合适的时机,例如 cell 的 prepareForReuse 方法内执行 unregisterDataObject 方法,
将广告对象与 GDTUnifiedNativeAdView 解绑,具体可参考示例 demo 的 UnifiedNativeAdBaseTableViewCell 类
*/
- (void)unregisterDataObject;
//#pragma mark - DEPRECATED
///**
// 此方法已经废弃
// 自渲染2.0视图注册方法
//
// @param dataObject 数据对象,必传字段
// @param logoView logo视图
// @param viewController 所在ViewController,必传字段。支持在register之后对其进行修改
// @param clickableViews 可点击的视图数组,此数组内的广告元素才可以响应广告对应的点击事件
// */
//- (void)registerDataObject:(GDTUnifiedNativeAdDataObject *)dataObject
// logoView:(GDTLogoView *)logoView
// viewController:(UIViewController *)viewController
// clickableViews:(NSArray<UIView *> *)clickableViews GDT_DEPRECATED_MSG_ATTRIBUTE("use registerDataObject:clickableViews: instead.");
//
//
///**
// 此方法已经废弃
// 自渲染2.0视图注册方法
//
// @param dataObject 数据对象,必传字段
// @param mediaView 媒体对象视图,此处放视频播放器的容器视图
// @param logoView logo视图
// @param viewController 所在ViewController,必传字段。支持在register之后对其进行修改
// @param clickableViews 可点击的视图数组,此数组内的广告元素才可以响应广告对应的点击事件
// */
//- (void)registerDataObject:(GDTUnifiedNativeAdDataObject *)dataObject
// mediaView:(GDTMediaView *)mediaView
// logoView:(GDTLogoView *)logoView
// viewController:(UIViewController *)viewController
// clickableViews:(NSArray<UIView *> *)clickableViews GDT_DEPRECATED_MSG_ATTRIBUTE("use registerDataObject:clickableViews: instead.");
@end
//
// GDTVideoConfig.h
// GDTMobApp
//
// Created by royqpwang on 2019/5/16.
// Copyright © 2019 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, GDTVideoAutoPlayPolicy) {
GDTVideoAutoPlayPolicyWIFI = 0, // WIFI 下自动播放
GDTVideoAutoPlayPolicyAlways = 1, // 总是自动播放,无论网络条件
GDTVideoAutoPlayPolicyNever = 2, // 从不自动播放,无论网络条件
};
NS_ASSUME_NONNULL_BEGIN
@interface GDTVideoConfig : NSObject
/**
视频自动播放策略,默认 GDTVideoAutoPlayPolicyAlways,
选择 GDTVideoAutoPlayPolicyNever 策略时,需要开发者调用 GDTMediaView 的 play\pause 方法触发视频播、暂停,
或者开启 userControlEnable 设置,让用户点击 MediaView 控制播放状态
*/
@property (nonatomic, assign) GDTVideoAutoPlayPolicy autoPlayPolicy;
/**
是否静音播放视频广告,视频初始状态是否静音,默认 YES,
可通过 GDTMediaView muteEnable: 方法实时控制播放器j静音状态,
*/
@property (nonatomic, assign) BOOL videoMuted;
/**
视频详情页播放时是否静音,默认NO,
*/
@property (nonatomic, assign) BOOL detailPageVideoMuted;
/**
是否启动自动续播功能,当在 tableView 等场景播放器被销毁时,广告展示时继续从上次播放位置续播,默认 NO
*/
@property (nonatomic, assign) BOOL autoResumeEnable;
/**
广告发生点击行为时,是否展示视频详情页
设为 NO 时,用户点击 clickableViews 会直接打开 App Store 或者广告落地页
*/
@property (nonatomic, assign) BOOL detailPageEnable;
/**
是否支持用户点击 MediaView 改变视频播放暂停状态,默认 NO
设为 YES 时,用户点击会切换播放器播放、暂停状态
*/
@property (nonatomic, assign) BOOL userControlEnable;
/**
是否展示播放进度条,默认 YES
*/
@property (nonatomic, assign) BOOL progressViewEnable;
/**
是否展示播放器封面图,默认 YES
*/
@property (nonatomic, assign) BOOL coverImageEnable;
@end
NS_ASSUME_NONNULL_END
//
// GYAdsManager+flow.h
// GYDemo
//
// Created by 明津李 on 2020/10/27.
//
#import "GYAdsManager.h"
NS_ASSUME_NONNULL_BEGIN
@interface GYAdsManager(Flow)
- (void)adsFlowForModel:(GYAdsTrackModel *)model;
@end
NS_ASSUME_NONNULL_END
//
// GYAdsManager+flow.m
// GYDemo
//
// Created by 明津李 on 2020/10/27.
//
#import "GYAdsManager+Flow.h"
@implementation GYAdsManager(Flow)
- (void)adsFlowForModel:(GYAdsTrackModel *)model{
self.currentAdsModel = model;
if ([model.adPlatform isEqualToString:@"chuanshanjia"]) {
[self feedForCSJ:model];
}else if ([model.adPlatform isEqualToString:@"guangdiantong"]){
[self feedForGDT:model];
}else if ([model.adPlatform isEqualToString:@"kuaishou"]){
[self feedForKS:model];
}
NSLog(@"common_bigimage============%@", model.adPlatform);
}
//CSJ
- (void)feedForCSJ:(GYAdsTrackModel *)model{
BUAdSlot *slot1 = [[BUAdSlot alloc] init];
slot1.ID = model.codeId;
slot1.AdType = BUAdSlotAdTypeFeed;
BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Feed228_150];
slot1.imgSize = imgSize;
slot1.position = BUAdSlotPositionFeed;
slot1.isSupportDeepLink = YES;
self.nativeExpressAdManager = [[BUNativeExpressAdManager alloc] initWithSlot:slot1 adSize:self.flowBgView.frame.size];
self.nativeExpressAdManager.delegate = self;
[self.nativeExpressAdManager loadAd:1];
}
//KS
- (void)feedForKS:(GYAdsTrackModel *)model{
self.feedAdsManager = [[KSFeedAdsManager alloc] initWithPosId:model.codeId size:CGSizeMake(self.flowBgView.frame.size.width, self.flowBgView.frame.size.height)];
self.feedAdsManager.delegate = self;
[self.feedAdsManager loadAdDataWithCount:1];
}
//GDT
- (void)feedForGDT:(GYAdsTrackModel *)model{
GDTAdParams *adParams = [[GDTAdParams alloc] init];
adParams.adSize = CGSizeMake(self.flowBgView.frame.size.width, self.flowBgView.frame.size.height);
adParams.maxVideoDuration = 5;
adParams.minVideoDuration = 30;
adParams.detailPageVideoMuted = YES;
adParams.videoMuted = YES;
adParams.videoAutoPlayOnWWAN = NO;
self.adManager = [[GDTNativeExpressProAdManager alloc] initWithPlacementId:model.codeId
adPrams:adParams];
self.adManager.delegate = self;
[self.adManager loadAd:1];
}
#pragma mark - CSJ BUNativeExpressAdViewDelegate
- (void)nativeExpressAdSuccessToLoad:(BUNativeExpressAdManager *)nativeExpressAd views:(NSArray<__kindof BUNativeExpressAdView *> *)views {
if (views.count) {
BUNativeExpressAdView *expressView = [views firstObject];
expressView.rootViewController = self.mainWindow.rootViewController;
[expressView render];
if (self.adsFinishCallBack) {
self.adsFinishCallBack(true, expressView);
}
}
}
- (void)nativeExpressAdFailToLoad:(BUNativeExpressAdManager *)nativeExpressAd error:(NSError *)error {
}
- (void)nativeExpressAdViewRenderSuccess:(BUNativeExpressAdView *)nativeExpressAdView {
}
- (void)nativeExpressAdView:(BUNativeExpressAdView *)nativeExpressAdView dislikeWithReason:(NSArray<BUDislikeWords *> *)filterWords {//【重要】需要在点击叉以后 在这个回调中移除视图,否则,会出现用户点击叉无效的情况
}
#pragma mark - KSFeedAdsManagerDelegate
- (void)feedAdsManagerSuccessToLoad:(KSFeedAdsManager *)adsManager nativeAds:(NSArray<KSFeedAd *> *_Nullable)feedAdDataArray {
KSFeedAd *feedAd = [adsManager.data firstObject];
feedAd.delegate = self;
if (self.adsFinishCallBack) {
self.adsFinishCallBack(true, feedAd.feedView);
}
}
- (void)feedAdsManager:(KSFeedAdsManager *)adsManager didFailWithError:(NSError *_Nullable)error {
}
#pragma mark - KSFeedAdDelegate
- (void)feedAdViewWillShow:(KSFeedAd *)feedAd {
}
- (void)feedAdDidClick:(KSFeedAd *)feedAd {
}
- (void)feedAdDislike:(KSFeedAd *)feedAd {
}
- (void)feedAdDidShowOtherController:(KSFeedAd *)nativeAd interactionType:(KSAdInteractionType)interactionType {
}
- (void)feedAdDidCloseOtherController:(KSFeedAd *)nativeAd interactionType:(KSAdInteractionType)interactionType {
}
#pragma mark - GDTNativeExpressProAdManagerDelegete
/**
* 拉取广告成功的回调
*/
- (void)gdt_nativeExpressProAdSuccessToLoad:(GDTNativeExpressProAdManager *)adManager views:(NSArray<__kindof GDTNativeExpressProAdView *> *)views
{
NSLog(@"%s",__FUNCTION__);
if (views.count > 0) {
GDTNativeExpressProAdView *adView = [views firstObject];
adView.controller = self.currentVC;
adView.delegate = self;
[adView render];
if (self.adsFinishCallBack) {
self.adsFinishCallBack(true, adView);
}
}
}
/**
* 拉取广告失败的回调
*/
- (void)gdt_nativeExpressProAdFailToLoad:(GDTNativeExpressProAdManager *)adManager error:(NSError *)error
{
NSLog(@"%s",__FUNCTION__);
NSLog(@"Express Ad Load Fail : %@",error);
}
#pragma mark - GDTNativeExpressProAdViewDelegate;
- (void)gdt_NativeExpressProAdViewRenderSuccess:(GDTNativeExpressProAdView *)nativeExpressAdView
{
NSLog(@"%s",__FUNCTION__);
}
- (void)gdt_NativeExpressProAdViewRenderFail:(GDTNativeExpressProAdView *)nativeExpressProAdView
{
}
- (void)gdt_NativeExpressProAdViewClicked:(GDTNativeExpressProAdView *)nativeExpressAdView
{
NSLog(@"%s",__FUNCTION__);
}
- (void)gdt_NativeExpressProAdViewClosed:(GDTNativeExpressProAdView *)nativeExpressAdView
{
NSLog(@"%s",__FUNCTION__);
}
- (void)gdt_NativeExpressProAdViewExposure:(GDTNativeExpressProAdView *)nativeExpressAdView
{
NSLog(@"%s",__FUNCTION__);
}
- (void)gdt_NativeExpressProAdViewWillPresentScreen:(GDTNativeExpressProAdView *)nativeExpressAdView
{
NSLog(@"%s",__FUNCTION__);
}
- (void)gdt_NativeExpressProAdViewDidPresentScreen:(GDTNativeExpressProAdView *)nativeExpressAdView
{
NSLog(@"%s",__FUNCTION__);
}
- (void)gdt_NativeExpressProAdViewWillDissmissScreen:(GDTNativeExpressProAdView *)nativeExpressAdView
{
NSLog(@"%s",__FUNCTION__);
}
- (void)gdt_NativeExpressProAdViewDidDissmissScreen:(GDTNativeExpressProAdView *)nativeExpressAdView
{
NSLog(@"%s",__FUNCTION__);
}
- (void)gdt_NativeExpressProAdView:(GDTNativeExpressProAdView *)nativeExpressProAdView playerStatusChanged:(GDTMediaPlayerStatus)status
{
NSLog(@"%s",__FUNCTION__);
}
@end
//
// GYAdsManager+OpenScreen.h
// GYDemo
//
// Created by 明津李 on 2020/10/27.
//
#import "GYAdsManager.h"
NS_ASSUME_NONNULL_BEGIN
@interface GYAdsManager(GYAdsManager_OpenScreen)
- (void)openScreenForModel:(GYAdsTrackModel *)model;
@end
NS_ASSUME_NONNULL_END
//
// GYAdsManager+OpenScreen.m
// GYDemo
//
// Created by 明津李 on 2020/10/27.
//
#import "GYAdsManager+OpenScreen.h"
@implementation GYAdsManager(GYAdsManager_OpenScreen)
- (void)openScreenForModel:(GYAdsTrackModel *)model{
self.currentAdsModel = model;
if ([model.adPlatform isEqualToString:@"chuanshanjia"]) {
[self openScreenAdsForCSJ:model];
}else if ([model.adPlatform isEqualToString:@"guangdiantong"]){
[self openScreenAdsForGDT:model];
}else if ([model.adPlatform isEqualToString:@"kuaishou"]){
[self openScreenAdsForKS:model];
}
}
//CSJ
- (void)openScreenAdsForCSJ:(GYAdsTrackModel *)model{
CGRect frame = [UIScreen mainScreen].bounds;
self.splashAd_CSJ = [[BUSplashAdView alloc] initWithSlotID:model.codeId frame:frame];
self.splashAd_CSJ.tolerateTimeout = 10;
self.splashAd_CSJ.delegate = self;
[self.splashAd_CSJ loadAdData];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.mainWindow.rootViewController.view addSubview:self.splashAd_CSJ];
self.splashAd_CSJ.rootViewController = self.mainWindow.rootViewController;
});
}
//GDT
- (void)openScreenAdsForGDT:(GYAdsTrackModel *)model{
self.splashAd_GDT = [[GDTSplashAd alloc] initWithPlacementId:@"9040714184494018"];
self.splashAd_GDT.delegate = self;
self.splashAd_GDT.fetchDelay = 5;
self.splashAd_GDT.backgroundImage = [UIImage imageNamed:@""];
self.splashAd_GDT.backgroundImage.accessibilityIdentifier = @"splash_ad";
[self.splashAd_GDT loadAd];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.splashAd_GDT showAdInWindow:self.mainWindow withBottomView:nil skipView:nil];
});
}
//KS
- (void)openScreenAdsForKS:(GYAdsTrackModel *)model{
KSAdSplashManager.posId = model.codeId;
KSAdSplashManager.interactDelegate = self;
[KSAdSplashManager loadSplash];
//如果有本地已缓存⼴广告,检测⼴广告是否有效,如果⼴广告有效,会返回开屏⼴广告控制器器,具体使⽤用可 ⻅见demo
[KSAdSplashManager checkSplash:^(KSAdSplashViewController * _Nonnull splashViewController) {
if (splashViewController) {
splashViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.mainWindow.rootViewController presentViewController:splashViewController animated:YES completion:nil];
});
}
}];
}
#pragma mark - CSJ BUSplashAdDelegate
- (void)splashAdDidClose:(BUSplashAdView *)splashAd {
[splashAd removeFromSuperview];
}
- (void)splashAd:(BUSplashAdView *)splashAd didFailWithError:(NSError *)error {
[splashAd removeFromSuperview];
}
- (void)splashAdWillVisible:(BUSplashAdView *)splashAd {
// NSString * clkTracking = self.currentAdsModel.imp_tracking[0];
// if (clkTracking.length > 0) {
// [[CGNetworkTools shared] pureGetWithAdsTrackingAction:clkTracking success:^(id _Nonnull response) {
//
// } failure:^(NSError * _Nonnull error) {
//
// }];
// }
}
- (void)splashAdDidClick:(BUSplashAdView *)splashAd {
// NSString * clkTracking = self.currentAdsModel.clk_tracking[0];
// if ([self.clk_tracking isEqualToString:clkTracking]) {
// return;
// }
// if (clkTracking.length > 0) {
// [[CGNetworkTools shared] pureGetWithAdsTrackingAction:clkTracking success:^(id _Nonnull response) {
// self.clk_tracking = clkTracking;
// } failure:^(NSError * _Nonnull error) {
//
// }];
// }
}
#pragma mark - GDTSplashAdDelegate
//- (void)splashAdDidLoad:(GDTSplashAd *)splashAd {
// NSLog(@"ecpmLevel:%@", splashAd.eCPMLevel);
//}
- (void)splashAdSuccessPresentScreen:(GDTSplashAd *)splashAd
{
NSLog(@"%s",__FUNCTION__);
}
- (void)splashAdFailToPresent:(GDTSplashAd *)splashAd withError:(NSError *)error
{
NSLog(@"%s%@",__FUNCTION__,error);
}
- (void)splashAdExposured:(GDTSplashAd *)splashAd
{
NSLog(@"%s",__FUNCTION__);
}
- (void)splashAdClicked:(GDTSplashAd *)splashAd
{
NSLog(@"%s",__FUNCTION__);
}
- (void)splashAdApplicationWillEnterBackground:(GDTSplashAd *)splashAd
{
NSLog(@"%s",__FUNCTION__);
}
- (void)splashAdWillClosed:(GDTSplashAd *)splashAd
{
NSLog(@"%s",__FUNCTION__);
}
- (void)splashAdClosed:(GDTSplashAd *)splashAd
{
NSLog(@"%s",__FUNCTION__);
}
- (void)splashAdWillPresentFullScreenModal:(GDTSplashAd *)splashAd
{
NSLog(@"%s",__FUNCTION__);
}
- (void)splashAdDidPresentFullScreenModal:(GDTSplashAd *)splashAd
{
NSLog(@"%s",__FUNCTION__);
}
- (void)splashAdWillDismissFullScreenModal:(GDTSplashAd *)splashAd
{
NSLog(@"%s",__FUNCTION__);
}
- (void)splashAdDidDismissFullScreenModal:(GDTSplashAd *)splashAd
{
NSLog(@"%s",__FUNCTION__);
}
#pragma mark - KS KSAdSplashInteractDelegate
- (void)ksad_splashAdDismiss:(BOOL)converted {
//convert为YES时需要直接隐藏掉splash,防⽌止影响后续转化⻚页⾯面展示
[self.mainWindow.rootViewController dismissViewControllerAnimated:!converted completion:nil];
NSLog(@"----%@", NSStringFromSelector(_cmd));
}
//开屏跳过
- (void)ksad_splashAdVideoDidSkipped:(NSTimeInterval)playDuration {
NSLog(@"----%@:%f", NSStringFromSelector(_cmd), playDuration);
}
//开屏点击
- (void)ksad_splashAdClicked {
NSLog(@"----%@", NSStringFromSelector(_cmd));
}
//开屏展示
- (void)ksad_splashAdDidShow {
NSLog(@"----%@", NSStringFromSelector(_cmd));
}
//开屏⼴广告开始播放
- (void)ksad_splashAdVideoDidStartPlay {
NSLog(@"----%@", NSStringFromSelector(_cmd));
}
//开屏⼴广告播放失败
- (void)ksad_splashAdVideoFailedToPlay:(NSError *)error {
NSLog(@"----%@, %@", NSStringFromSelector(_cmd), error);
}
//开屏⼴广告转化根控制器器,默认keyWindow.rootViewController
- (UIViewController *)ksad_splashAdConversionRootVC {
return self.mainWindow.rootViewController;
}
@end
//
// GYAdsManager+RewardedVideo.h
// GYDemo
//
// Created by 明津李 on 2020/10/27.
//
#import "GYAdsManager.h"
NS_ASSUME_NONNULL_BEGIN
@interface GYAdsManager(RewardedVideo)
- (void)rewardedVideoForModel:(GYAdsTrackModel *)model;
- (void)playVideo;
@end
NS_ASSUME_NONNULL_END
This diff is collapsed.
//
// GYAdsManager.h
// GYDemo
//
// Created by 明津李 on 2020/10/27.
//
#import <Foundation/Foundation.h>
#import "GYAdsTrackModel.h"
#import <BUAdSDK/BUAdSDK.h>
#import <KSAdSDK/KSAdSDK.h>
#import "GDTSplashAd.h"
#import "GDTNativeExpressProAdManager.h"
#import "GDTNativeExpressProAdView.h"
#import "GDTRewardVideoAd.h"
#import "GDTSDKConfig.h"
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
OpenScreen_ads,
Video_ads,
Bigimage_ads,
} GYAdsType;
typedef void (^adsCallBack)(BOOL result, UIView * _Nullable flowView);
@interface GYAdsManager : NSObject<BUSplashAdDelegate, GDTSplashAdDelegate, KSAdSplashInteractDelegate, BUNativeExpressAdViewDelegate, KSFeedAdsManagerDelegate, KSFeedAdDelegate, GDTNativeExpressProAdManagerDelegate, GDTNativeExpressProAdViewDelegate, BUNativeExpressRewardedVideoAdDelegate, KSRewardedVideoAdDelegate, GDTRewardedVideoAdDelegate>
+ (instancetype)shared;
- (void)initWithAdsType:(GYAdsType)type window:(UIWindow *)mainWindow currentVC:(UIViewController *)currentVC flowBgView:(UIView * _Nullable)flowBgView callBack:(adsCallBack)callback;
- (void)play;
@property (nonatomic, strong) UIWindow * mainWindow;
@property (nonatomic, strong) UIViewController * currentVC;
@property (nonatomic, strong) UIView * flowBgView;
@property (nonatomic, copy) adsCallBack adsFinishCallBack;
@property (nonatomic, strong) GYAdsTrackModel * currentAdsModel;
//穿山甲ads
@property (nonatomic, strong) BUSplashAdView *splashAd_CSJ;
@property (nonatomic, strong) BUNativeExpressAdManager * nativeExpressAdManager;
@property (nonatomic, strong) BUNativeExpressRewardedVideoAd * rewardedAd;
//广点通
@property (nonatomic, strong) GDTSplashAd *splashAd_GDT;
@property (nonatomic, strong) GDTNativeExpressProAdManager *adManager;
@property (nonatomic, strong) GDTRewardVideoAd *rewardVideoAd;
//快手
@property (nonatomic, strong) KSFeedAdsManager *feedAdsManager;
@property (nonatomic, strong) KSRewardedVideoAd *rewardedVideoAd;
@property (nonatomic, copy) NSString *clk_tracking;
@end
NS_ASSUME_NONNULL_END
//
// GYAdsManager.m
// GYDemo
//
// Created by 明津李 on 2020/10/27.
//
#import "GYAdsManager.h"
#import "GYAdsTrackModel.h"
#import "GYAdsManager+OpenScreen.h"
#import "GYAdsManager+Flow.h"
#import "GYAdsManager+RewardedVideo.h"
static GYAdsManager * manager;
@implementation GYAdsManager
+ (instancetype)shared{
static dispatch_once_t o;
dispatch_once(&o, ^{
manager = [[GYAdsManager alloc] init];
});
return manager;
}
- (instancetype)init{
if (self = [super init]) {
}
return self;
}
+ (instancetype)alloc{
if (manager) {
// 如果单例对象存在则抛出异常
NSException *exception = [NSException exceptionWithName:[NSString stringWithFormat:@"重复创建%@单例对象 异常", [self class]] reason:@"请使用单例" userInfo:nil];
[exception raise];
}
return [super alloc]; // 如果单例对象不存在 正常创建
}
- (id)copyWithZone:(struct _NSZone *)zone{
return manager;
}
+ (id)allocWithZone:(struct _NSZone *)zone{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
manager = [super allocWithZone:zone];
});
return manager;
}
- (void)initWithAdsType:(GYAdsType)type window:(UIWindow *)mainWindow currentVC:(UIViewController *)currentVC flowBgView:(UIView *)flowBgView callBack:(adsCallBack)callback{
_mainWindow = mainWindow;
_adsFinishCallBack = callback;
_flowBgView = flowBgView;
_currentVC = currentVC;
switch (type) {
case OpenScreen_ads:
[self openScreen];
break;
case Video_ads:
[self rewardedVideo];
break;
case Bigimage_ads:
[self AdsFlow];
break;
default:
break;
}
}
- (void)openScreen{
[[CGNetworkTools shared] getWithAdsAction:getAdsInfo parameters: @{@"slotName": @"splash"} success:^(id _Nonnull response) {
if ([[response objectForKey:@"status"] intValue] == 200) {
NSMutableArray * models = [NSMutableArray new];
NSArray * arr = response[@"result"][@"data"];
for (NSDictionary * dict in arr) {
GYAdsTrackModel * model = [GYAdsTrackModel new];
[model setValuesForKeysWithDictionary:dict];
[models addObject:model];
}
[self openScreenForModel:models.firstObject];
}else{
if (self.adsFinishCallBack) {
self.adsFinishCallBack(false, nil);
}
}
} failure:^(NSError * _Nonnull error) {
if (self.adsFinishCallBack) {
self.adsFinishCallBack(false, nil);
}
}];
}
- (void)AdsFlow{
[[CGNetworkTools shared] getWithAdsAction:getAdsInfo parameters: @{@"slotName": @"common_bigimage"} success:^(id _Nonnull response) {
if ([[response objectForKey:@"status"] intValue] == 200) {
NSMutableArray * models = [NSMutableArray new];
NSArray * arr = response[@"result"][@"data"];
for (NSDictionary * dict in arr) {
GYAdsTrackModel * model = [GYAdsTrackModel new];
[model setValuesForKeysWithDictionary:dict];
[models addObject:model];
}
GYAdsTrackModel * model = models.firstObject;
[self adsFlowForModel:model];
}else{
if (self.adsFinishCallBack) {
self.adsFinishCallBack(false, nil);
}
}
} failure:^(NSError * _Nonnull error) {
if (self.adsFinishCallBack) {
self.adsFinishCallBack(false, nil);
}
}];
}
- (void)rewardedVideo{
[[CGNetworkTools shared] getWithAdsAction:getAdsInfo parameters: @{@"slotName": @"common_video"} success:^(id _Nonnull response) {
if ([[response objectForKey:@"status"] intValue] == 200) {
NSMutableArray * models = [NSMutableArray new];
NSArray * arr = response[@"result"][@"data"];
for (NSDictionary * dict in arr) {
GYAdsTrackModel * model = [GYAdsTrackModel new];
[model setValuesForKeysWithDictionary:dict];
[models addObject:model];
}
GYAdsTrackModel * model = models.firstObject;
[self rewardedVideoForModel:model];
}else{
if (self.adsFinishCallBack) {
self.adsFinishCallBack(false, nil);
}
}
} failure:^(NSError * _Nonnull error) {
if (self.adsFinishCallBack) {
self.adsFinishCallBack(false, nil);
}
}];
}
- (void)play{
[self playVideo];
}
@end
//
// ICAdsTrackModel.m
// GYAdsTrackModel.m
// ios-clear
//
// Created by Mazy on 2020/8/3.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICAdsTrackModel.h"
#import "GYAdsTrackModel.h"
@implementation ICAdsTrackModel
@implementation GYAdsTrackModel
+(instancetype)modelWithDic:(NSDictionary *)dict{
ICAdsTrackModel *obj = [[ICAdsTrackModel alloc] init];
GYAdsTrackModel *obj = [[GYAdsTrackModel alloc] init];
[obj setValuesForKeysWithDictionary:dict];
return obj;
}
......
//
// ICAdsTrackModel.h
// GYAdsTrackModel.h
// ios-clear
//
// Created by Mazy on 2020/8/3.
......@@ -7,10 +7,11 @@
//
#import <Foundation/Foundation.h>
#import "GYBaseModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface ICAdsTrackModel : NSObject
@interface GYAdsTrackModel : GYBaseModel
@property (nonatomic ,strong) NSString *adPlatform;
@property (nonatomic ,assign) NSInteger adType;
......
//
// ICCustomLaunchScreenView.h
// ios-clear
//
// Created by Mazy on 2020/8/3.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICCustomLaunchScreenView : UIView
+(ICCustomLaunchScreenView *)loadFromNib;
- (void)showWithView: (UIView *)toView;
- (void)dismiss;
@end
NS_ASSUME_NONNULL_END
//
// ICCustomLaunchScreenView.m
// ios-clear
//
// Created by Mazy on 2020/8/3.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICCustomLaunchScreenView.h"
@implementation ICCustomLaunchScreenView
+(ICCustomLaunchScreenView *)loadFromNib {
return [[UINib nibWithNibName:@"ICCustomLaunchScreenView" bundle:nil] instantiateWithOwner:self options:nil].firstObject;
}
- (void)showWithView: (UIView *)toView {
self.frame = toView.bounds;
[toView addSubview:self];
}
- (void)dismiss {
__weak typeof(self) wkSelf = self;
[UIView animateWithDuration:0.25 animations:^{
wkSelf.alpha = 0;
} completion:^(BOOL finished) {
[wkSelf removeFromSuperview];
}];
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="ICCustomLaunchScreenView">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="screen_launch_icon" translatesAutoresizingMaskIntoConstraints="NO" id="2pZ-V0-QGW">
<rect key="frame" x="93.5" y="290.5" width="227" height="205"/>
</imageView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="2pZ-V0-QGW" firstAttribute="centerX" secondItem="vUN-kp-3ea" secondAttribute="centerX" id="c3i-Rh-U1A"/>
<constraint firstItem="2pZ-V0-QGW" firstAttribute="centerY" secondItem="vUN-kp-3ea" secondAttribute="centerY" constant="-60" id="sRf-Tm-P86"/>
</constraints>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<point key="canvasLocation" x="141" y="154"/>
</view>
</objects>
<resources>
<image name="screen_launch_icon" width="227" height="205"/>
</resources>
</document>
......@@ -8,6 +8,7 @@
#import "GYSettingViewController.h"
#import "GYSettingCell.h"
#import "GYWebViewController.h"
#import "GYAdsManager.h"
@interface GYSettingViewController ()<UITableViewDelegate, UITableViewDataSource>{
UIColor * titleColor;
......@@ -18,6 +19,8 @@
@property (nonatomic, weak) IBOutlet UIView * headerView;
@property (nonatomic, weak) IBOutlet UILabel * idLab;
@property (nonatomic, weak) IBOutlet UIView * adsBgView;
@property (nonatomic, weak) IBOutlet NSLayoutConstraint * adsHeightConstraint;
@property (nonatomic, weak) IBOutlet NSLayoutConstraint * tableViewHeightConstraint;
@property (nonatomic, weak) IBOutlet UITableView * tableView;
......@@ -61,9 +64,11 @@
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = self.view.backgroundColor;
_headerView.frame = CGRectMake(0, 0, _tableView.frame.size.width, 60); //207
_headerView.frame = CGRectMake(0, 0, _tableView.frame.size.width, 337); //337
_headerView.backgroundColor = [UIColor whiteColor];
_tableView.tableHeaderView = _headerView;
_tableViewHeightConstraint.constant = _headerView.frame.size.height + 300;
_tableView.layer.borderWidth = 2.5;
_tableView.layer.borderColor = [UIColor colorWithRed:153/255.0 green:74/255.0 blue:0/255.0 alpha:1.0].CGColor;
_tableView.layer.cornerRadius = 8;
......@@ -75,6 +80,8 @@
}
_idLab.text = [NSString stringWithFormat:@"ID: %@", [CGUserManager shared].uid];
[self getAdsDataSource];
}
- (IBAction)copyBtn:(UIButton *)sender{
......@@ -82,6 +89,17 @@
pasteboard.string = [NSString stringWithFormat:@"%@", [CGUserManager shared].uid];
}
- (void)getAdsDataSource{
[[GYAdsManager shared] initWithAdsType:Bigimage_ads window:self.view.window currentVC:self flowBgView:_adsBgView callBack:^(BOOL result, UIView * _Nullable flowView) {
self.adsHeightConstraint.constant = flowView.frame.size.height;
self.headerView.frame = CGRectMake(0, 0, self.tableView.frame.size.width, flowView.frame.size.height+77);
self.tableViewHeightConstraint.constant = self.headerView.frame.size.height + 300 < KScreenHeight-SafeAreaTopHeight ? self.headerView.frame.size.height + 300 : KScreenHeight-SafeAreaTopHeight;
[self.tableView reloadData];
[self.adsBgView addSubview:flowView];
}];
}
#pragma mark tableView
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _dataSourceArray.count;
......
......@@ -9,6 +9,7 @@
#import "GYWheelSurfModel.h"
#import "GYRedPacketView.h"
#import "GYGiftAlertView.h"
#import "GYAdsManager.h"
@interface GYWheelSurfViewController ()<CAAnimationDelegate>
......@@ -23,6 +24,8 @@
@property (nonatomic, strong) GYRedPacketView * redPacket;
@property (nonatomic, strong) GYGiftAlertView * gift;
@property (nonatomic, assign) BOOL isVideo;
@end
#define perSection M_PI*2/8
......@@ -54,6 +57,8 @@
} failure:^(NSError * _Nonnull error) {
}];
[self getVideoDataSource];
}
- (IBAction)startBtn:(UIButton *)sender{
......@@ -84,8 +89,13 @@
[model.extModels addObject:extModel];
}
}
self.remainderCount = model.lotteryNum;
if (model.showVideo != 0){
self.isVideo = true;
}
NSArray * seedIndexs = @[@1, @3, @5];
NSArray * goldIndexs = @[@2, @4, @6];
......@@ -129,6 +139,16 @@
}
- (void)getVideoDataSource{
[[GYAdsManager shared] initWithAdsType:Video_ads window:self.view.window currentVC:self flowBgView:nil callBack:^(BOOL result, UIView * _Nullable flowView) {
if (result && flowView) {
[[GYAdsManager shared] play];
}
}];
}
- (void)goRed:(GYWheelSurfModel *)model{
_redPacket = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([GYRedPacketView class]) owner:self options:nil].firstObject;
_redPacket.awardNum = model.awardNum;
......
......@@ -14,5 +14,7 @@ target 'GYDemo' do
pod 'MBProgressHUD'
pod 'SwiftyStoreKit'
pod 'WechatOpenSDK'
pod 'Bytedance-UnionAD'
pod 'KSAdSDK'
end
......@@ -14,6 +14,8 @@ PODS:
- AFNetworking/Serialization (4.0.1)
- AFNetworking/UIKit (4.0.1):
- AFNetworking/NSURLSession
- Bytedance-UnionAD (3.2.5.2)
- KSAdSDK (3.3.3)
- Masonry (1.1.0)
- MBProgressHUD (1.2.0)
- SwiftyStoreKit (0.16.1)
......@@ -21,6 +23,8 @@ PODS:
DEPENDENCIES:
- AFNetworking
- Bytedance-UnionAD
- KSAdSDK
- Masonry
- MBProgressHUD
- SwiftyStoreKit
......@@ -29,6 +33,8 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- AFNetworking
- Bytedance-UnionAD
- KSAdSDK
- Masonry
- MBProgressHUD
- SwiftyStoreKit
......@@ -36,11 +42,13 @@ SPEC REPOS:
SPEC CHECKSUMS:
AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce
Bytedance-UnionAD: 097cb648f7ae8895f28d79edda6a2fac466b6028
KSAdSDK: b7914b4d3947f4a8ac89c83bab78dac87a151f6d
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
MBProgressHUD: 3ee5efcc380f6a79a7cc9b363dd669c5e1ae7406
SwiftyStoreKit: 6b9c08810269f030586dac1fae8e75871a82e84a
WechatOpenSDK: 6a4d1436c15b3b5fe2a0bd383f3046010186da44
PODFILE CHECKSUM: 36d5be77bb71c126a061125c50b0bde3f15e34ef
PODFILE CHECKSUM: ec131953948f8835d71213b1d489b418fad6c044
COCOAPODS: 1.9.3
/*
BULanguage.strings
BUAdSDK
Created by wangyanlin on 2020/4/10.
Copyright © 2020 bytedance. All rights reserved.
*/
// String
"Click" = "انقر فوق";
"AD" = "الإعلان";
"PlayConsumed" = "سيؤدي تشغيل هذا إلى استخدام بيانات تبلغ %.2f ميجابايت";
"Evaluation" = "التقييم";
"Score" = "تصنيف (تصنيفات) %@";
"Select" = "اختر";
"Back" = "رجوع";
"Replay" = "انقر لإعادة التشغيل";
"Continue" = "المتابعة للتشغيل";
"Skip" = "تخطي";
"Feedback" = "التعليقات";
"FeedbackStr1" = "شكرًا لك على تعليقك.";
"FeedbackStr2" = "سنبذل قصارى جهدنا لمنحك تجربة إعلانية أفضل";
"FeedbackStr3" = "لقد أرسلت تعليق بالفعل.";
"FeedbackStr4" = "يرجى عدم الإرسال أكثر من مرة!";
"ViewNow" = "عرض الآن";
"Download" = "تنزيل";
"LoadFailure" = "تعذر التحميل. يرجى المحاولة مرة أخرى.";
"GetRewardAfterWatching" = "قم بإستكمال مشاهدة الفيديو بالكامل للحصول على مكافآت";
"GiveUpReward" = "تخطي المكافآت";
"ContinueWatching" = "متابعة المشاهدة";
"CanbeTurnedOffAfter" = "s %d تخطي بعد";
"Get" = "تنزيل";
"View" = "عرض";
"ContinuePlaying" = "متابعة التشغيل";
"GetRewardAfterPlaying" = "قم بإستكمال التشغيل للحصول على المكافآت";
"Wan" = "10 ألف";
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment