123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854 |
- //
- // RQADViewManager.m
- // jiaPei
- //
- // Created by 张嵘 on 2021/4/29.
- // Copyright © 2021 JCZ. All rights reserved.
- //
- #import "RQADViewManager.h"
- //#import <AppTrackingTransparency/AppTrackingTransparency.h>
- //#import <AdSupport/AdSupport.h>
- //#import <ADSuyiSDK/ADSuyiSDK.h>
- //#import <ADSuyiSDK/ADSuyiSDKSplashAd.h>
- //#import <ADSuyiKit/UIColor+ADSuyiKit.h>
- //#import <ADSuyiKit/ADSuyiKitMacros.h>
- //#import <ADSuyiKit/ADSuyiKitLogging.h>
- //#import "YYTimer.h"
- //
- //// 支持广点通开屏广告v+
- //#define SUPPORT_SPLASH_ZOOMOUT 1
- //
- //#if defined(__IPHONE_14_0)
- //#import <AppTrackingTransparency/AppTrackingTransparency.h>//适配iOS14
- //#endif
- //
- //static RQADViewManager *manger = nil;
- //static dispatch_once_t onceToken;
- //
- //static NSString *appId = @"3841183";
- //static NSString *splashPlcId = @"cca7ca16b609a5f82f";
- //static NSString *bannerPlcId = @"11b78db61106501a5a";
- //static NSString *bannerPlcId2 = @"f082b7423186d1ebe7";
- //static NSString *nativeAdPlcId = @"83ee3c7b2b70351e79";
- //static NSString *fullScreenvodAdPlcId = @"5641600669408f2cf3";
- //
- //
- //@interface RQADViewManager () <ADSuyiSDKBannerAdViewDelegate, ADSuyiSDKNativeAdDelegate,ADSuyiSDKIntertitialAdDelegate,
- //#ifdef SUPPORT_SPLASH_ZOOMOUT
- //ADSuyiSDKSplashAdZoomOutViewDelegate,
- //#endif
- //ADSuyiSDKSplashAdDelegate
- //>
- ///* 插屏广告 */
- ////@property (nonatomic,strong) ADCDN_InterstitialAdManager *interstitialAdManager;
- ///* 开屏广告对象 */
- //@property (nonatomic, readwrite, strong) ADSuyiSDKSplashAd *splashAd;
- ///* 横幅广告 */
- //@property (nonatomic, readwrite, strong) ADSuyiSDKBannerAdView *bannerView;
- ///* 信息流广告 */
- //@property (nonatomic, readwrite, strong) ADSuyiSDKNativeAd *nativeAd;
- ///* 全屏视频广告 */
- //@property (nonatomic, readwrite, strong) ADSuyiSDKIntertitialAd *fullScreenvodAd;
- //
- //
- //@property (nonatomic, readwrite, strong) UIView<ADSuyiAdapterNativeAdViewDelegate> *currentAdView;
- //
- //@property (nonatomic, readwrite, strong) UIView *customView;
- //@property (nonatomic, readwrite, strong) UIViewController *customViewController;
- //
- //@property (nonatomic ,strong) dispatch_source_t myTimer;// 注意:此处应该使用强引用 strong
- //@property (nonatomic, readwrite, assign) BOOL isResume;
- //
- //@property (nonatomic, readwrite, assign) RQADType adType;
- //@property (nonatomic, readwrite, strong) RQADCloseCompletedBlock aDCloseCompletedBlock;
- //
- //@property (nonatomic, readwrite, strong) UIButton *skipBtn;
- //@property (nonatomic, readwrite, strong) YYTimer *timer;
- //@property (nonatomic, readwrite, assign) NSUInteger count;
- //
- //@property (nonatomic, readwrite, assign) BOOL isReady;
- //@property (nonatomic, readwrite, assign) BOOL isCanShow;
- //@end
- //
- //@implementation RQADViewManager
- //
- //#pragma mark - SystemMethod
- //+ (RQADViewManager *)sharedManager {
- // dispatch_once(&onceToken, ^{
- // manger = [[self alloc] init];
- // });
- // return manger;
- //}
- //
- //- (instancetype)init {
- // self = [super init];
- // if (self) {
- // [self initBaseData];
- // }
- // return self;
- //}
- //
- //- (void)dealloc {
- // [self stopTimer];
- //}
- //
- //
- //#pragma mark - PublicMethods
- //- (void)loadAdWithAdType:(RQADType)adType customView:(UIView * _Nullable )customView {
- // [self loadAdWithAdType:adType customView:customView cycleSecound:0.f];
- //}
- //
- //- (void)loadAdWithAdType:(RQADType)adType customView:(UIView * _Nullable )customView cycleSecound:(CGFloat)second {
- // [self loadAdWithAdType:adType customView:customView controller:RQControllerHelper.currentViewController cycleSecound:second hidden:NO];
- //}
- //
- //- (void)loadAdWithAdType:(RQADType)adType customView:(UIView * _Nullable )customView controller:(UIViewController *)controller cycleSecound:(CGFloat)second hidden:(BOOL)hidden {
- // @weakify(self)
- // self.adType = adType;
- // self.customView = customView;
- // self.customViewController = controller;
- //
- // /// 服务端允许展示广告
- //// if (RQ_SHARE_FUNCTION.APP_AD) {
- // switch (adType) {
- // case RQADType_Splash: {
- // /// 不展示广告在有引导页的时候
- //// if (!myDelegate.adIsShow) {
- // [self setThirtyPartySdk];
- //// }
- // break;
- // }
- // case RQADType_Banner: {
- // self.bannerView.delegate = nil;
- // self.bannerView = nil;
- // [self.customView addSubview:self.bannerView];
- // if (hidden) {
- // [self.customView sendSubviewToBack:self.bannerView];
- // }
- // [self.bannerView loadAndShow];
- //
- // if (second > 0) {
- // RACSignal *deallocSignal = [RQ_COMMON_MANAGER.bannerOnVC rac_signalForSelector:@selector(viewWillDisappear:)];
- // [[[[RACSignal interval:second onScheduler:[RACScheduler scheduler]] takeUntil: deallocSignal] deliverOnMainThread] subscribeNext:^(NSDate * _Nullable x) {
- // if (!RQObjectIsNil(_bannerView)) {
- // @strongify(self)
- // [self.bannerView removeFromSuperview];
- // self.bannerView.delegate = nil;
- // self.bannerView = nil;
- // [self.customView addSubview:self.bannerView];
- // if (hidden) {
- // [self.customView sendSubviewToBack:self.bannerView];
- // }
- // [self.bannerView loadAndShow];
- // } else {
- // [self.customView addSubview:self.bannerView];
- // if (hidden) {
- // [self.customView sendSubviewToBack:self.bannerView];
- // }
- // [self.bannerView loadAndShow];
- // }
- // }];
- // }
- // break;
- // }
- // case RQADType_native: {
- // [self.nativeAd load:1];
- // }
- // break;
- // case RQADType_fullScreen: {
- // self.isReady = NO;
- // _fullScreenvodAd = nil;
- // [self.fullScreenvodAd loadAdData];
- // }
- // break;
- // default:
- // break;
- // }
- //// }
- //}
- //
- //- (void)showAdWithAdType:(RQADType)adType {
- //// if (RQ_SHARE_FUNCTION.APP_AD) {
- // switch (adType) {
- // case RQADType_fullScreen: {
- // if (self.isReady) {
- // self.isCanShow = YES;
- // [self.fullScreenvodAd show];
- // }
- // }
- // break;
- // default:
- // break;
- // }
- //// }
- //}
- //
- //- (void)removeBanner {
- // if (_bannerView) {
- // [_bannerView removeFromSuperview];
- // _bannerView = nil;
- // }
- //}
- //
- //- (void)initCloseBlock:(RQADCloseCompletedBlock)block {
- // self.aDCloseCompletedBlock = block;
- //}
- //
- //#pragma mark - Action
- //- (void)_timerValueChanged:(YYTimer *)timer {
- // self.count--;
- // if (self.count == 0) {
- // [timer invalidate];
- // self.timer = nil;
- // [self.skipBtn setTitleNormal:@"跳过"];
- // if (self.currentAdView) {
- // [self.currentAdView adsy_close];
- // }
- // return;
- // }
- // [self.skipBtn setTitleNormal:[NSString stringWithFormat:@"跳过 %zd", self.count]];
- //}
- //
- //#pragma mark - PrivateMethods
- //- (void)setThirtyPartySdk {
- // if ([self isFirstAppLoad]) {
- // [self showAgreePrivacy];
- // }else {
- // [self initADSuyiSDK];
- // }
- //}
- //
- //- (void)initADSuyiSDK {
- // // 设置日志输出等级
- // [ADSuyiSDK setLogLevel:ADSuyiKitLogLevelDebug];
- // // ADSuyiSDK初始化
- // [ADSuyiSDK initWithAppId:appId completionBlock:^(NSError * _Nonnull error) {
- // if (error) {
- // NSLog(@"SDK 初始化失败:%@", error.localizedDescription);
- // }
- // }];
- // /*
- // * 推荐在AppDelegate中的最后加载开屏广告
- // * 其他的接入方式会有需要特殊注意的方式,遇到过的相关问题在SDK相关问题的文档中有提到
- // */
- // [self loadSplashAd];
- //
- //}
- //
- //- (void)showAgreePrivacy {
- // // 隐私合规化示例
- // // 隐私合规化示例
- // NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
- // // app名称
- // NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
- // NSString *messageStr = [NSString stringWithFormat:@"亲爱的用户,欢迎您信任并使用【%@】,我们依据相关法律制定了《用户协议》和《隐私协议》帮你你了解我们手机,使用,存储和共享个人信息情况,请你在点击之前仔细阅读并理解相关条款。\n1、在使用我们的产品和服务时,将会提供与具体功能有关的个法人信息(可能包括身份验证,位置信息,设备信息和操作日志等)\n2、我们会采用业界领先的安全技术来保护你的个人隐私,未经授权许可我们不会讲上述信息共享给任何第三方或用于未授权的其他用途。\n如你同意请点击同意按钮并继续。",app_Name];
- // UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"温馨提示" message:messageStr preferredStyle:(UIAlertControllerStyleAlert)];
- // UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"不同意" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:@"点击同意才能使用该App服务" preferredStyle:(UIAlertControllerStyleAlert)];
- // UIAlertAction *sure = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
- //
- // [RQControllerHelper.currentViewController presentViewController:alertVc animated:YES completion:nil];
- // }];
- // [alert addAction:sure];
- // [RQControllerHelper.currentViewController presentViewController:alert animated:YES completion:nil];
- // }];
- // UIAlertAction *agree = [UIAlertAction actionWithTitle:@"同意并继续" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
- // // 记录是否第一次启动
- // [self writeAppLoad];
- // // 获取idfa权限 建议启动就获取权限 不获取权限会影响收益
- // if (@available(iOS 14.0, *)) {
- // [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
- //
- // }];
- // }
- // // 用户同意隐私后 初始化
- // [self initADSuyiSDK];
- //
- // }];
- // [alertVc addAction:cancle];
- // [alertVc addAction:agree];
- // [RQControllerHelper.currentViewController presentViewController:alertVc animated:YES completion:nil];
- //}
- //
- //#pragma mark -- helper
- //
- //- (void)writeAppLoad {
- // NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
- // [userDefault setObject:@"yes" forKey:@"isFirstLoad"];
- // [userDefault synchronize];
- //}
- //
- //- (BOOL)isFirstAppLoad {
- // NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
- // if ([[userDefault objectForKey:@"isFirstLoad"] isEqualToString:@"yes"]) {
- // return NO;
- // }
- // return YES;
- //}
- //
- //- (void)loadSplashAd{
- // if (self.splashAd) {
- // return;
- // }
- // // 1、初始化开屏广告实例对象
- // self.splashAd = [[ADSuyiSDKSplashAd alloc]init];
- // self.splashAd.delegate = self;
- //#ifdef SUPPORT_SPLASH_ZOOMOUT
- // self.splashAd.zoomOutViewDelegate = self;
- //#endif
- // self.splashAd.controller = RQControllerHelper.currentViewController;
- // // 2、设置开屏的广告位id
- // self.splashAd.posId = splashPlcId;
- // /**
- // 开屏请求总超时时间:所有平台轮询的请求等待总时长(不包括图片渲染时间),单位秒,推荐设置为4s,最小值为3s
- // 开屏各平台分配逻辑:(目前只有开屏需要分配时间,并且理论上分配给到各平台的超时时间不会完全耗尽)
- // 1、3<=tolerateTimeout<=4:轮询首位平台的超时时间为(tolerateTimeout-1)s,次位为2s,如果后续还有平台统一为1s;
- // 2、tolerateTimeout>=5:轮询首位平台的超时时间为(tolerateTimeout-2)s,次位为3s,如果后续还有平台统一为2s;
- // */
- // self.splashAd.tolerateTimeout = 4;
- // // 3、设置默认启动图(一般设置启动图的平铺颜色为背景颜色,使得视觉效果更加平滑)
- // UIViewController * vc = [[UIStoryboard storyboardWithName:@"LaunchScreen" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
- // CGRect rect = [UIScreen mainScreen].bounds;
- // UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f);
- // CGContextRef context = UIGraphicsGetCurrentContext();
- // vc.view.frame = rect;
- // [vc.view.layer renderInContext:context];
- // UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
- // UIGraphicsEndImageContext();
- // self.splashAd.backgroundColor = [UIColor adsy_getColorWithImage:image withNewSize:[UIScreen mainScreen].bounds.size];
- //
- // // 4、开屏广告机型适配
- // CGFloat bottomViewHeight;
- // if (kADSYCurveScreen) { // 刘海屏
- // bottomViewHeight = [UIScreen mainScreen].bounds.size.height * 0.15;
- // } else {
- // bottomViewHeight = [UIScreen mainScreen].bounds.size.height - [UIScreen mainScreen].bounds.size.width * (960 / 640.0);
- // }
- //
- // // 7、加载开屏广告
- //// [self.splashAd loadAndShowInWindow:RQ_APPDELEGATE.window];
- //
- //}
- //
- //- (void)initBaseData {
- // [[[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil] map:^id(NSNotification *value) {
- // return value.object;
- // }] distinctUntilChanged] subscribeNext:^(id x) {
- // NSLog(@"%@",@"APP进入后台");
- // }];
- //}
- //
- ////获取当前屏幕显示的viewcontroller
- //- (UIViewController *)getCurrentVC {
- // UIViewController *resultVC;
- // resultVC = [self _topViewController:[[UIApplication sharedApplication].keyWindow rootViewController]];
- //
- // /// RQ Fixed : 这里必须要判断一下,否则取出来永远都是 RQMainTabBarViewController。这是架构上小缺(特)陷(性)。因为RQMainTabBarViewController的子控制器是UITabBarController,所以需要递归UITabBarController的所有的子控制器
- // if ([resultVC isKindOfClass:[RQTableViewController class]]) {
- // RQTableViewController *mainVc = (RQTableViewController *)resultVC;
- // resultVC = [self _topViewController:mainVc.tabBarController];
- // }
- //
- // return resultVC;
- //}
- //
- //- (UIViewController *)_topViewController:(UIViewController *)vc {
- // if ([vc isKindOfClass:[UINavigationController class]]) {
- // return [self _topViewController:[(UINavigationController *)vc topViewController]];
- // } else if ([vc isKindOfClass:[UITabBarController class]]) {
- // return [self _topViewController:[(UITabBarController *)vc selectedViewController]];
- // } else {
- // return vc;
- // }
- //}
- //
- //- (void)initTimerWithSecound:(CGFloat)second {
- // //2.设置时间等
- // /*
- // 第一个参数:定时器对象
- // 第二个参数:DISPATCH_TIME_NOW 表示从现在开始计时
- // 第三个参数:间隔时间 GCD里面的时间最小单位为 纳秒
- // 第四个参数:精准度(表示允许的误差,0表示绝对精准)
- // */
- // dispatch_source_set_timer(self.myTimer, DISPATCH_TIME_NOW, second * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
- //
- // //3.要调用的任务
- // dispatch_source_set_event_handler(self.myTimer, ^{
- // NSLog(@"GCD-----%@",[NSThread currentThread]);
- //// [self.bannerAdManager loadNativeAd];
- //// if (![[self getCurrentVC] isKindOfClass:[ExerciseVC class]]) {
- //// NSLog(@"%s",object_getClassName([self getCurrentVC]));
- //// [self stopTimer];
- //// }
- // });
- //}
- //
- //- (void)pauseTimer {
- // if (self.myTimer) {
- // dispatch_suspend(_myTimer);
- // }
- //}
- //
- //- (void)resumeTimer {
- // if (_myTimer) {
- // dispatch_resume(_myTimer);
- // self.isResume = YES;
- // }
- //}
- //
- //- (void)stopTimer {
- // self.isResume = NO;
- // if (_myTimer) {
- // dispatch_source_cancel(_myTimer);
- // _myTimer = nil;
- // }
- //}
- //
- //
- //#pragma mark - ADSuyiSDKSplashAdDelegate
- ///**
- // 开屏展现成功
- //
- // @param splashAd 广告实例
- // */
- //- (void)adsy_splashAdSuccessToPresentScreen:(ADSuyiSDKSplashAd *)splashAd{
- //#ifdef SUPPORT_SPLASH_ZOOMOUT
- // if(splashAd.splashZoomOutView) {
- // UIViewController *rootVc = [UIApplication sharedApplication].keyWindow.rootViewController;
- // [rootVc.view addSubview:splashAd.splashZoomOutView];
- // }
- //#endif
- //}
- //
- ///**
- // 开屏展现失败
- //
- // @param splashAd 广告实例
- // @param error 具体错误信息
- // */
- //- (void)adsy_splashAdFailToPresentScreen:(ADSuyiSDKSplashAd *)splashAd failToPresentScreen:(ADSuyiAdapterErrorDefine *)error{
- // _splashAd = nil;
- //}
- //
- ///**
- // 开屏广告点击
- //
- // @param splashAd 广告实例
- // */
- //- (void)adsy_splashAdClicked:(ADSuyiSDKSplashAd *)splashAd{
- //
- //}
- //
- ///**
- // 开屏被关闭
- //
- // @param splashAd 广告实例
- // */
- //- (void)adsy_splashAdClosed:(ADSuyiSDKSplashAd *)splashAd{
- //#ifdef SUPPORT_SPLASH_ZOOMOUT
- // if(_splashAd.splashZoomOutView == nil)
- // _splashAd = nil;
- //#else
- // _splashAd = nil;
- //#endif
- //}
- //
- ///**
- // 开屏展示
- //
- // @param splashAd 广告实例
- // */
- //- (void)adsy_splashAdEffective:(ADSuyiSDKSplashAd *)splashAd{
- //
- //}
- //
- //#ifdef SUPPORT_SPLASH_ZOOMOUT
- //
- //#pragma mark - ADSuyiSDKSplashAdZoomOutViewDelegate
- //
- ///**
- // ZoomOutView被点击
- //
- // @param splashAd 广告实例
- // @param splashZoomOutView zoomOutView
- // */
- //- (void)adsy_splashZoomOutViewDidClick:(ADSuyiSDKSplashAd *)splashAd
- // splashZoomOutView:(__kindof UIView <ADSuyiSDKSplashAdZoomOutViewProtocol>*)splashZoomOutView {
- //
- //}
- //
- ///**
- // ZoomOutView 被关闭
- //
- // @param splashAd 广告实例
- // @param splashZoomOutView zoomOutView
- // */
- //- (void)adsy_splashZoomOutViewAdDidClose:(ADSuyiSDKSplashAd *)splashAd
- // splashZoomOutView:(__kindof UIView <ADSuyiSDKSplashAdZoomOutViewProtocol>*)splashZoomOutView {
- //
- //}
- //
- ///**
- // ZoomOutView 播放完成
- //
- // @param splashAd 广告实例
- // @param splashZoomOutView zoomOutView
- // */
- //- (void)adsy_splashZoomOutViewAdVideoFinished:(ADSuyiSDKSplashAd *)splashAd
- // splashZoomOutView:(__kindof UIView <ADSuyiSDKSplashAdZoomOutViewProtocol>*)splashZoomOutView {
- //
- //}
- //
- ///**
- // ZoomOutView 进入视频详情页
- //
- // @param splashAd 广告实例
- // @param splashZoomOutView zoomOutView
- // */
- //- (void)adsy_splashZoomOutViewAdDidPresentFullScreenModal:(ADSuyiSDKSplashAd *)splashAd
- // splashZoomOutView:(__kindof UIView <ADSuyiSDKSplashAdZoomOutViewProtocol>*)splashZoomOutView {
- //
- //}
- //
- ///**
- // ZoomOutView 退出视频详情页
- //
- // @param splashAd 广告实例
- // @param splashZoomOutView zoomOutView
- // */
- //- (void)adsy_splashZoomOutViewAdDidDismissFullScreenModal:(ADSuyiSDKSplashAd *)splashAd
- // splashZoomOutView:(__kindof UIView <ADSuyiSDKSplashAdZoomOutViewProtocol>*)splashZoomOutView {
- // _splashAd = nil;
- //}
- //
- //#endif
- //
- //
- //#pragma mark - ADSuyiSDKBannerAdViewDelegate
- ///**
- // 广告获取成功
- //
- // @param bannerView banner实例
- // */
- //- (void)adsy_bannerViewDidReceived:(ADSuyiSDKBannerAdView *)bannerView{
- // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Success) : nil;
- //}
- //
- ///**
- // 广告拉取失败
- //
- // @param bannerView banner实例
- // @param errorModel 错误描述
- // */
- //- (void)adsy_bannerViewFailToReceived:(ADSuyiSDKBannerAdView *)bannerView errorModel:(ADSuyiAdapterErrorDefine *)errorModel{
- // NSLog(@"adsy_bannerViewFailToReceived:%@, %@",errorModel.errorDescription, errorModel.errorDetailDict);
- // [self removeBanner];
- // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Faild) : nil;
- //}
- //
- ///**
- // 广告点击
- //
- // @param bannerView 广告实例
- // */
- //- (void)adsy_bannerViewClicked:(ADSuyiSDKBannerAdView *)bannerView{
- //
- //}
- //
- ///**
- // 广告关闭
- //
- // @param bannerView 广告实例
- // */
- //- (void)adsy_bannerViewClose:(ADSuyiSDKBannerAdView *)bannerView{
- // [self removeBanner];
- // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Close) : nil;
- //}
- //
- ///**
- // 广告展示
- //
- // @param bannerView 广告实例
- // */
- //- (void)adsy_bannerViewExposure:(ADSuyiSDKBannerAdView *)bannerView{
- //
- //}
- //
- //#pragma mark - ADSuyiSDKNativeAdDelegate
- //
- //- (void)adsy_nativeAdSucessToLoad:(ADSuyiSDKNativeAd *)nativeAd
- // adViewArray:(NSArray<__kindof UIView<ADSuyiAdapterNativeAdViewDelegate> *> *)adViewArray {
- // for (UIView<ADSuyiAdapterNativeAdViewDelegate> *adView in adViewArray) {
- // // 4、判断信息流广告是否为自渲染类型(可选实现) 可仿照所示样式demo实现 如无所需样式则需自行实现
- // // 如果单纯只配置了模版信息流,那么不需要实现,如果配置了自渲染信息流,那么需要实现
- // if(adView.renderType == ADSuyiAdapterRenderTypeNative) {
- // // 4.1、如果是自渲染类型则可样式自定义(3种示例demo样式见下)
- // // 1、常规样式
- //// [self setUpUnifiedTopImageNativeAdView:adView];
- // // 2、纯图样式
- // [self setUpUnifiedOnlyImageNativeAdView:adView];
- // // 3、上图下文
- //// [self setUpUnifiedTopImageNativeAdView:adView];
- // }
- // // 5、注册,自渲染:注册点击事件,模板:render,重要
- // [adView adsy_registViews:@[adView]];
- //
- // // 广点通视频信息流广告会给mediaView添加事件,点击会出现半屏广告,以下为广点通官方给予的解决方案
- // if([adView.adsy_platform isEqualToString:ADSuyiAdapterPlatformGDT]
- // && adView.renderType == ADSuyiAdapterRenderTypeNative
- // && adView.data.shouldShowMediaView) {
- // UIView *mediaView = [adView adsy_mediaViewForWidth:0.0];
- // mediaView.userInteractionEnabled = NO;
- // }
- // }
- //}
- //
- //- (void)adsy_nativeAdFailToLoad:(ADSuyiSDKNativeAd *)nativeAd
- // errorModel:(ADSuyiAdapterErrorDefine *)errorModel {
- // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Faild) : nil;
- //}
- //- (void)adsy_nativeAdViewRenderOrRegistSuccess:(UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
- // self.currentAdView = adView;
- // [self.customView addSubview:self.currentAdView];
- //
- //}
- //- (void)adsy_nativeAdViewRenderOrRegistFail:(UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
- // self.currentAdView = adView;
- // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Faild) : nil;
- //}
- //- (void)adsy_nativeAdClicked:(ADSuyiSDKNativeAd *)nativeAd
- // adView:(__kindof UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
- // self.currentAdView = adView;
- // [adView adsy_close];
- //}
- //- (void)adsy_nativeAdClose:(ADSuyiSDKNativeAd *)nativeAd
- // adView:(__kindof UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
- // if (self.currentAdView) {
- // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Close) : nil;
- // self.currentAdView = adView;
- // [self.currentAdView removeFromSuperview];
- // [self.skipBtn removeFromSuperview];
- // self.currentAdView = nil;
- // self.nativeAd = nil;
- // }
- //}
- //- (void)adsy_nativeAdExposure:(ADSuyiSDKNativeAd *)nativeAd
- // adView:(__kindof UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
- // self.currentAdView = adView;
- // [self.customView bringSubviewToFront:self.skipBtn];
- // self.count = 5;
- // [_skipBtn setTitleNormal:@"跳过 5"];
- // self.timer = [YYTimer timerWithTimeInterval:1 target:self selector:@selector(_timerValueChanged:) repeats:YES];
- // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Success) : nil;
- //}
- //
- //#pragma mark - Helper 自渲染类型信息流处理方法 setUpUnifiedOnlyImageNativeAdView纯图样式
- //// 纯图样式
- //- (void)setUpUnifiedOnlyImageNativeAdView:(UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
- // // 设计的adView实际大小,其中宽度和高度可以自己根据自己的需求设置
- // CGFloat adWidth = self.customView.frame.size.width;
- // CGFloat adHeight = adWidth / 16.0 * 9;
- // adView.frame = CGRectMake(0, 0, adWidth, adHeight);
- //
- // // 设置主图/视频(主图可选,但强烈建议带上,如果有视频试图,则必须带上)
- // CGRect mainFrame = CGRectMake(0, 0, adWidth, adHeight);
- // if(adView.data.shouldShowMediaView) {
- // UIView *mediaView = [adView adsy_mediaViewForWidth:mainFrame.size.width];
- // mediaView.frame = mainFrame;
- // [adView addSubview:mediaView];
- // } else {
- // UIImageView *imageView = [UIImageView new];
- // imageView.backgroundColor = [UIColor adsy_colorWithHexString:@"#CCCCCC"];
- // [adView addSubview:imageView];
- // imageView.frame = mainFrame;
- // NSString *urlStr = adView.data.imageUrl;
- // if(urlStr.length > 0) {
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
- // UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlStr]]];
- // dispatch_async(dispatch_get_main_queue(), ^{
- // imageView.image = image;
- // });
- // });
- // }
- // }
- //
- // // 展示关闭按钮(必要)
- // [self.customView addSubview:self.skipBtn];
- // self.skipBtn.frame = CGRectMake(adWidth - 12 - 54, 12, 54, 27);
- // [self.skipBtn addTarget:adView action:@selector(adsy_close) forControlEvents:UIControlEventTouchUpInside];
- //
- // // 显示logo图片(必要)
- // if(![adView.adsy_platform isEqualToString:ADSuyiAdapterPlatformGDT]) { // 优量汇(广点通)会自带logo,不需要添加
- // UIImageView *logoImage = [UIImageView new];
- // [adView addSubview:logoImage];
- //// [adView bringSubviewToFront:logoImage];
- // [adView adsy_platformLogoImageDarkMode:NO loadImageBlock:^(UIImage * _Nullable image) {
- // CGFloat maxWidth = 40;
- // CGFloat logoHeight = maxWidth / image.size.width * image.size.height;
- // logoImage.frame = CGRectMake(adWidth - maxWidth, adHeight - logoHeight, maxWidth, logoHeight);
- // logoImage.image = image;
- // }];
- // }
- //}
- //
- //#pragma mark - ADSuyiSDKIntertitialAdDelegate
- ///**
- // ADSuyiSDKIntertitialAd请求成功回调
- //
- // @param interstitialAd 插屏广告实例对象
- //*/
- //- (void)adsy_interstitialAdSuccedToLoad:(ADSuyiSDKIntertitialAd *)interstitialAd {
- // self.isReady = YES;
- // if (!RQ_Video_Module.playerController.isPlaying && self.adType == RQADType_fullScreen && self.isCanShow && _fullScreenvodAd) {
- // [_fullScreenvodAd show];
- // }
- //}
- //
- ///**
- // ADSuyiSDKIntertitialAd请求失败回调
- //
- // @param interstitialAd 插屏广告实例对象
- // @param error 失败原因
- //*/
- //- (void)adsy_interstitialAdFailedToLoad:(ADSuyiSDKIntertitialAd *)interstitialAd error:(ADSuyiAdapterErrorDefine *)error {
- // _fullScreenvodAd = nil;
- //}
- //
- ///**
- // ADSuyiSDKIntertitialAd展示在屏幕内回调
- //
- // @param interstitialAd 插屏广告实例对象
- //*/
- //- (void)adsy_interstitialAdDidPresent:(ADSuyiSDKIntertitialAd *)interstitialAd {
- //
- //}
- //
- ///**
- // ADSuyiSDKIntertitialAd展示在屏幕内失败回调
- //
- // @param interstitialAd 插屏广告实例对象
- //*/
- //- (void)adsy_interstitialAdFailedToPresent:(ADSuyiSDKIntertitialAd *)interstitialAd error:(NSError *)error {
- //
- //}
- //
- ///**
- // ADSuyiSDKIntertitialAd点击回调
- //
- // @param interstitialAd 插屏广告实例对象
- //*/
- //- (void)adsy_interstitialAdDidClick:(ADSuyiSDKIntertitialAd *)interstitialAd {
- //
- //}
- //
- ///**
- // ADSuyiSDKIntertitialAd关闭回调
- //
- // @param interstitialAd 插屏广告实例对象
- //*/
- //- (void)adsy_interstitialAdDidClose:(ADSuyiSDKIntertitialAd *)interstitialAd {
- //
- //}
- //
- ///**
- // ADSuyiSDKIntertitialAd展示回调
- //
- // @param interstitialAd 广告实例
- // */
- //- (void)adsy_interstitialAdExposure:(ADSuyiSDKIntertitialAd *)interstitialAd {
- //
- //}
- //
- //#pragma mark - LazyLoad
- //- (dispatch_source_t)myTimer {
- // if (!_myTimer) {
- // //0.创建队列
- // dispatch_queue_t queue = dispatch_get_main_queue();
- // //1.创建GCD中的定时器
- // /*
- // 第一个参数:创建source的类型 DISPATCH_SOURCE_TYPE_TIMER:定时器
- // 第二个参数:0
- // 第三个参数:0
- // 第四个参数:队列
- // */
- // _myTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
- // }
- // return _myTimer;
- //}
- //
- //- (UIView *)customView {
- // if (!_customView) {
- // CGRect rect;
- // switch (self.adType) {
- // case RQADType_Splash:
- // rect = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT * 0.75);
- // break;
- // case RQADType_Banner:
- // rect = CGRectMake(25, (RQ_SCREEN_HEIGHT - RQ_APPLICATION_TOP_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT) - 60 - 40, RQ_SCREEN_WIDTH - 50, 50);
- // default:
- // rect = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT);
- // break;
- // }
- // _customView = [[UIView alloc] initWithFrame:rect];
- // }
- // return _customView;
- //}
- //
- //- (ADSuyiSDKBannerAdView *)bannerView {
- // if (!_bannerView) {
- // // 1、初始化banner视图,并给定frame值,rate取值根据banner的尺寸
- // _bannerView = [[ADSuyiSDKBannerAdView alloc] initWithFrame:CGRectMake(0, 0, self.customView.width, self.customView.height)];
- // _bannerView.delegate = self;
- // // 2、设置控制器,用来弹出落地页,重要
- // _bannerView.controller = self.customViewController;
- // // 3、设置广告位id,重要
- // CGFloat a = RQ_SCREEN_WIDTH / (640/100.0);
- // if (self.customView.height > a) {
- // _bannerView.posId = bannerPlcId2;
- // } else {
- // _bannerView.posId = bannerPlcId;
- // }
- // // 可设置bannerview的背景色,请按需添加修改该行代码
- // _bannerView.backgroundColor = UIColor.whiteColor;
- // }
- // return _bannerView;
- //}
- //
- //- (ADSuyiSDKNativeAd *)nativeAd {
- // if (!_nativeAd) {
- // _nativeAd = [[ADSuyiSDKNativeAd alloc] initWithAdSize:self.customView.size];
- // _nativeAd.delegate = self;
- // _nativeAd.controller = RQControllerHelper.currentViewController;
- // _nativeAd.posId = nativeAdPlcId;
- // }
- // return _nativeAd;
- //}
- //
- //- (ADSuyiSDKIntertitialAd *)fullScreenvodAd {
- // if (!_fullScreenvodAd) {
- // _fullScreenvodAd = [ADSuyiSDKIntertitialAd new];
- // UIViewController *vc = RQControllerHelper.currentViewController;
- // _fullScreenvodAd.controller = vc;
- // _fullScreenvodAd.posId = fullScreenvodAdPlcId;
- // _fullScreenvodAd.delegate = self;
- // _fullScreenvodAd.tolerateTimeout = 4;
- // _fullScreenvodAd.adSize = CGSizeMake(vc.view.frame.size.width, vc.view.frame.size.height);
- // }
- // return _fullScreenvodAd;
- //}
- //
- //- (UIButton *)skipBtn {
- // if (!_skipBtn) {
- // _skipBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- // _skipBtn.frame = CGRectMake(RQ_SCREEN_WIDTH - 54 - 12, 12, 54, 27);
- // [_skipBtn setBackgroundColor:[UIColor colorWithWhite:0.1 alpha:0.3]];
- //// [_skipBtn setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithWhite:0.1 alpha:1] size:CGSizeMake(200, 200)] forState:UIControlStateNormal];
- // _skipBtn.titleLabel.font = RQRegularFont(13);
- // [_skipBtn setTitleNormal:@"跳过 5"];
- // _skipBtn.layer.cornerRadius = 13.5;
- // _skipBtn.clipsToBounds = YES;
- // }
- // return _skipBtn;
- //}
- //@end
|