RQADViewManager.m 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. //
  2. // RQADViewManager.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2021/4/29.
  6. // Copyright © 2021 JCZ. All rights reserved.
  7. //
  8. #import "RQADViewManager.h"
  9. //#import <AppTrackingTransparency/AppTrackingTransparency.h>
  10. //#import <AdSupport/AdSupport.h>
  11. //#import <ADSuyiSDK/ADSuyiSDK.h>
  12. //#import <ADSuyiSDK/ADSuyiSDKSplashAd.h>
  13. //#import <ADSuyiKit/UIColor+ADSuyiKit.h>
  14. //#import <ADSuyiKit/ADSuyiKitMacros.h>
  15. //#import <ADSuyiKit/ADSuyiKitLogging.h>
  16. //#import "YYTimer.h"
  17. //
  18. //// 支持广点通开屏广告v+
  19. //#define SUPPORT_SPLASH_ZOOMOUT 1
  20. //
  21. //#if defined(__IPHONE_14_0)
  22. //#import <AppTrackingTransparency/AppTrackingTransparency.h>//适配iOS14
  23. //#endif
  24. //
  25. //static RQADViewManager *manger = nil;
  26. //static dispatch_once_t onceToken;
  27. //
  28. //static NSString *appId = @"3841183";
  29. //static NSString *splashPlcId = @"cca7ca16b609a5f82f";
  30. //static NSString *bannerPlcId = @"11b78db61106501a5a";
  31. //static NSString *bannerPlcId2 = @"f082b7423186d1ebe7";
  32. //static NSString *nativeAdPlcId = @"83ee3c7b2b70351e79";
  33. //static NSString *fullScreenvodAdPlcId = @"5641600669408f2cf3";
  34. //
  35. //
  36. //@interface RQADViewManager () <ADSuyiSDKBannerAdViewDelegate, ADSuyiSDKNativeAdDelegate,ADSuyiSDKIntertitialAdDelegate,
  37. //#ifdef SUPPORT_SPLASH_ZOOMOUT
  38. //ADSuyiSDKSplashAdZoomOutViewDelegate,
  39. //#endif
  40. //ADSuyiSDKSplashAdDelegate
  41. //>
  42. ///* 插屏广告 */
  43. ////@property (nonatomic,strong) ADCDN_InterstitialAdManager *interstitialAdManager;
  44. ///* 开屏广告对象 */
  45. //@property (nonatomic, readwrite, strong) ADSuyiSDKSplashAd *splashAd;
  46. ///* 横幅广告 */
  47. //@property (nonatomic, readwrite, strong) ADSuyiSDKBannerAdView *bannerView;
  48. ///* 信息流广告 */
  49. //@property (nonatomic, readwrite, strong) ADSuyiSDKNativeAd *nativeAd;
  50. ///* 全屏视频广告 */
  51. //@property (nonatomic, readwrite, strong) ADSuyiSDKIntertitialAd *fullScreenvodAd;
  52. //
  53. //
  54. //@property (nonatomic, readwrite, strong) UIView<ADSuyiAdapterNativeAdViewDelegate> *currentAdView;
  55. //
  56. //@property (nonatomic, readwrite, strong) UIView *customView;
  57. //@property (nonatomic, readwrite, strong) UIViewController *customViewController;
  58. //
  59. //@property (nonatomic ,strong) dispatch_source_t myTimer;// 注意:此处应该使用强引用 strong
  60. //@property (nonatomic, readwrite, assign) BOOL isResume;
  61. //
  62. //@property (nonatomic, readwrite, assign) RQADType adType;
  63. //@property (nonatomic, readwrite, strong) RQADCloseCompletedBlock aDCloseCompletedBlock;
  64. //
  65. //@property (nonatomic, readwrite, strong) UIButton *skipBtn;
  66. //@property (nonatomic, readwrite, strong) YYTimer *timer;
  67. //@property (nonatomic, readwrite, assign) NSUInteger count;
  68. //
  69. //@property (nonatomic, readwrite, assign) BOOL isReady;
  70. //@property (nonatomic, readwrite, assign) BOOL isCanShow;
  71. //@end
  72. //
  73. //@implementation RQADViewManager
  74. //
  75. //#pragma mark - SystemMethod
  76. //+ (RQADViewManager *)sharedManager {
  77. // dispatch_once(&onceToken, ^{
  78. // manger = [[self alloc] init];
  79. // });
  80. // return manger;
  81. //}
  82. //
  83. //- (instancetype)init {
  84. // self = [super init];
  85. // if (self) {
  86. // [self initBaseData];
  87. // }
  88. // return self;
  89. //}
  90. //
  91. //- (void)dealloc {
  92. // [self stopTimer];
  93. //}
  94. //
  95. //
  96. //#pragma mark - PublicMethods
  97. //- (void)loadAdWithAdType:(RQADType)adType customView:(UIView * _Nullable )customView {
  98. // [self loadAdWithAdType:adType customView:customView cycleSecound:0.f];
  99. //}
  100. //
  101. //- (void)loadAdWithAdType:(RQADType)adType customView:(UIView * _Nullable )customView cycleSecound:(CGFloat)second {
  102. // [self loadAdWithAdType:adType customView:customView controller:RQControllerHelper.currentViewController cycleSecound:second hidden:NO];
  103. //}
  104. //
  105. //- (void)loadAdWithAdType:(RQADType)adType customView:(UIView * _Nullable )customView controller:(UIViewController *)controller cycleSecound:(CGFloat)second hidden:(BOOL)hidden {
  106. // @weakify(self)
  107. // self.adType = adType;
  108. // self.customView = customView;
  109. // self.customViewController = controller;
  110. //
  111. // /// 服务端允许展示广告
  112. //// if (RQ_SHARE_FUNCTION.APP_AD) {
  113. // switch (adType) {
  114. // case RQADType_Splash: {
  115. // /// 不展示广告在有引导页的时候
  116. //// if (!myDelegate.adIsShow) {
  117. // [self setThirtyPartySdk];
  118. //// }
  119. // break;
  120. // }
  121. // case RQADType_Banner: {
  122. // self.bannerView.delegate = nil;
  123. // self.bannerView = nil;
  124. // [self.customView addSubview:self.bannerView];
  125. // if (hidden) {
  126. // [self.customView sendSubviewToBack:self.bannerView];
  127. // }
  128. // [self.bannerView loadAndShow];
  129. //
  130. // if (second > 0) {
  131. // RACSignal *deallocSignal = [RQ_COMMON_MANAGER.bannerOnVC rac_signalForSelector:@selector(viewWillDisappear:)];
  132. // [[[[RACSignal interval:second onScheduler:[RACScheduler scheduler]] takeUntil: deallocSignal] deliverOnMainThread] subscribeNext:^(NSDate * _Nullable x) {
  133. // if (!RQObjectIsNil(_bannerView)) {
  134. // @strongify(self)
  135. // [self.bannerView removeFromSuperview];
  136. // self.bannerView.delegate = nil;
  137. // self.bannerView = nil;
  138. // [self.customView addSubview:self.bannerView];
  139. // if (hidden) {
  140. // [self.customView sendSubviewToBack:self.bannerView];
  141. // }
  142. // [self.bannerView loadAndShow];
  143. // } else {
  144. // [self.customView addSubview:self.bannerView];
  145. // if (hidden) {
  146. // [self.customView sendSubviewToBack:self.bannerView];
  147. // }
  148. // [self.bannerView loadAndShow];
  149. // }
  150. // }];
  151. // }
  152. // break;
  153. // }
  154. // case RQADType_native: {
  155. // [self.nativeAd load:1];
  156. // }
  157. // break;
  158. // case RQADType_fullScreen: {
  159. // self.isReady = NO;
  160. // _fullScreenvodAd = nil;
  161. // [self.fullScreenvodAd loadAdData];
  162. // }
  163. // break;
  164. // default:
  165. // break;
  166. // }
  167. //// }
  168. //}
  169. //
  170. //- (void)showAdWithAdType:(RQADType)adType {
  171. //// if (RQ_SHARE_FUNCTION.APP_AD) {
  172. // switch (adType) {
  173. // case RQADType_fullScreen: {
  174. // if (self.isReady) {
  175. // self.isCanShow = YES;
  176. // [self.fullScreenvodAd show];
  177. // }
  178. // }
  179. // break;
  180. // default:
  181. // break;
  182. // }
  183. //// }
  184. //}
  185. //
  186. //- (void)removeBanner {
  187. // if (_bannerView) {
  188. // [_bannerView removeFromSuperview];
  189. // _bannerView = nil;
  190. // }
  191. //}
  192. //
  193. //- (void)initCloseBlock:(RQADCloseCompletedBlock)block {
  194. // self.aDCloseCompletedBlock = block;
  195. //}
  196. //
  197. //#pragma mark - Action
  198. //- (void)_timerValueChanged:(YYTimer *)timer {
  199. // self.count--;
  200. // if (self.count == 0) {
  201. // [timer invalidate];
  202. // self.timer = nil;
  203. // [self.skipBtn setTitleNormal:@"跳过"];
  204. // if (self.currentAdView) {
  205. // [self.currentAdView adsy_close];
  206. // }
  207. // return;
  208. // }
  209. // [self.skipBtn setTitleNormal:[NSString stringWithFormat:@"跳过 %zd", self.count]];
  210. //}
  211. //
  212. //#pragma mark - PrivateMethods
  213. //- (void)setThirtyPartySdk {
  214. // if ([self isFirstAppLoad]) {
  215. // [self showAgreePrivacy];
  216. // }else {
  217. // [self initADSuyiSDK];
  218. // }
  219. //}
  220. //
  221. //- (void)initADSuyiSDK {
  222. // // 设置日志输出等级
  223. // [ADSuyiSDK setLogLevel:ADSuyiKitLogLevelDebug];
  224. // // ADSuyiSDK初始化
  225. // [ADSuyiSDK initWithAppId:appId completionBlock:^(NSError * _Nonnull error) {
  226. // if (error) {
  227. // NSLog(@"SDK 初始化失败:%@", error.localizedDescription);
  228. // }
  229. // }];
  230. // /*
  231. // * 推荐在AppDelegate中的最后加载开屏广告
  232. // * 其他的接入方式会有需要特殊注意的方式,遇到过的相关问题在SDK相关问题的文档中有提到
  233. // */
  234. // [self loadSplashAd];
  235. //
  236. //}
  237. //
  238. //- (void)showAgreePrivacy {
  239. // // 隐私合规化示例
  240. // // 隐私合规化示例
  241. // NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
  242. // // app名称
  243. // NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
  244. // NSString *messageStr = [NSString stringWithFormat:@"亲爱的用户,欢迎您信任并使用【%@】,我们依据相关法律制定了《用户协议》和《隐私协议》帮你你了解我们手机,使用,存储和共享个人信息情况,请你在点击之前仔细阅读并理解相关条款。\n1、在使用我们的产品和服务时,将会提供与具体功能有关的个法人信息(可能包括身份验证,位置信息,设备信息和操作日志等)\n2、我们会采用业界领先的安全技术来保护你的个人隐私,未经授权许可我们不会讲上述信息共享给任何第三方或用于未授权的其他用途。\n如你同意请点击同意按钮并继续。",app_Name];
  245. // UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"温馨提示" message:messageStr preferredStyle:(UIAlertControllerStyleAlert)];
  246. // UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"不同意" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  247. // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:@"点击同意才能使用该App服务" preferredStyle:(UIAlertControllerStyleAlert)];
  248. // UIAlertAction *sure = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
  249. //
  250. // [RQControllerHelper.currentViewController presentViewController:alertVc animated:YES completion:nil];
  251. // }];
  252. // [alert addAction:sure];
  253. // [RQControllerHelper.currentViewController presentViewController:alert animated:YES completion:nil];
  254. // }];
  255. // UIAlertAction *agree = [UIAlertAction actionWithTitle:@"同意并继续" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
  256. // // 记录是否第一次启动
  257. // [self writeAppLoad];
  258. // // 获取idfa权限 建议启动就获取权限 不获取权限会影响收益
  259. // if (@available(iOS 14.0, *)) {
  260. // [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
  261. //
  262. // }];
  263. // }
  264. // // 用户同意隐私后 初始化
  265. // [self initADSuyiSDK];
  266. //
  267. // }];
  268. // [alertVc addAction:cancle];
  269. // [alertVc addAction:agree];
  270. // [RQControllerHelper.currentViewController presentViewController:alertVc animated:YES completion:nil];
  271. //}
  272. //
  273. //#pragma mark -- helper
  274. //
  275. //- (void)writeAppLoad {
  276. // NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
  277. // [userDefault setObject:@"yes" forKey:@"isFirstLoad"];
  278. // [userDefault synchronize];
  279. //}
  280. //
  281. //- (BOOL)isFirstAppLoad {
  282. // NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
  283. // if ([[userDefault objectForKey:@"isFirstLoad"] isEqualToString:@"yes"]) {
  284. // return NO;
  285. // }
  286. // return YES;
  287. //}
  288. //
  289. //- (void)loadSplashAd{
  290. // if (self.splashAd) {
  291. // return;
  292. // }
  293. // // 1、初始化开屏广告实例对象
  294. // self.splashAd = [[ADSuyiSDKSplashAd alloc]init];
  295. // self.splashAd.delegate = self;
  296. //#ifdef SUPPORT_SPLASH_ZOOMOUT
  297. // self.splashAd.zoomOutViewDelegate = self;
  298. //#endif
  299. // self.splashAd.controller = RQControllerHelper.currentViewController;
  300. // // 2、设置开屏的广告位id
  301. // self.splashAd.posId = splashPlcId;
  302. // /**
  303. // 开屏请求总超时时间:所有平台轮询的请求等待总时长(不包括图片渲染时间),单位秒,推荐设置为4s,最小值为3s
  304. // 开屏各平台分配逻辑:(目前只有开屏需要分配时间,并且理论上分配给到各平台的超时时间不会完全耗尽)
  305. // 1、3<=tolerateTimeout<=4:轮询首位平台的超时时间为(tolerateTimeout-1)s,次位为2s,如果后续还有平台统一为1s;
  306. // 2、tolerateTimeout>=5:轮询首位平台的超时时间为(tolerateTimeout-2)s,次位为3s,如果后续还有平台统一为2s;
  307. // */
  308. // self.splashAd.tolerateTimeout = 4;
  309. // // 3、设置默认启动图(一般设置启动图的平铺颜色为背景颜色,使得视觉效果更加平滑)
  310. // UIViewController * vc = [[UIStoryboard storyboardWithName:@"LaunchScreen" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
  311. // CGRect rect = [UIScreen mainScreen].bounds;
  312. // UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f);
  313. // CGContextRef context = UIGraphicsGetCurrentContext();
  314. // vc.view.frame = rect;
  315. // [vc.view.layer renderInContext:context];
  316. // UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
  317. // UIGraphicsEndImageContext();
  318. // self.splashAd.backgroundColor = [UIColor adsy_getColorWithImage:image withNewSize:[UIScreen mainScreen].bounds.size];
  319. //
  320. // // 4、开屏广告机型适配
  321. // CGFloat bottomViewHeight;
  322. // if (kADSYCurveScreen) { // 刘海屏
  323. // bottomViewHeight = [UIScreen mainScreen].bounds.size.height * 0.15;
  324. // } else {
  325. // bottomViewHeight = [UIScreen mainScreen].bounds.size.height - [UIScreen mainScreen].bounds.size.width * (960 / 640.0);
  326. // }
  327. //
  328. // // 7、加载开屏广告
  329. //// [self.splashAd loadAndShowInWindow:RQ_APPDELEGATE.window];
  330. //
  331. //}
  332. //
  333. //- (void)initBaseData {
  334. // [[[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil] map:^id(NSNotification *value) {
  335. // return value.object;
  336. // }] distinctUntilChanged] subscribeNext:^(id x) {
  337. // NSLog(@"%@",@"APP进入后台");
  338. // }];
  339. //}
  340. //
  341. ////获取当前屏幕显示的viewcontroller
  342. //- (UIViewController *)getCurrentVC {
  343. // UIViewController *resultVC;
  344. // resultVC = [self _topViewController:[[UIApplication sharedApplication].keyWindow rootViewController]];
  345. //
  346. // /// RQ Fixed : 这里必须要判断一下,否则取出来永远都是 RQMainTabBarViewController。这是架构上小缺(特)陷(性)。因为RQMainTabBarViewController的子控制器是UITabBarController,所以需要递归UITabBarController的所有的子控制器
  347. // if ([resultVC isKindOfClass:[RQTableViewController class]]) {
  348. // RQTableViewController *mainVc = (RQTableViewController *)resultVC;
  349. // resultVC = [self _topViewController:mainVc.tabBarController];
  350. // }
  351. //
  352. // return resultVC;
  353. //}
  354. //
  355. //- (UIViewController *)_topViewController:(UIViewController *)vc {
  356. // if ([vc isKindOfClass:[UINavigationController class]]) {
  357. // return [self _topViewController:[(UINavigationController *)vc topViewController]];
  358. // } else if ([vc isKindOfClass:[UITabBarController class]]) {
  359. // return [self _topViewController:[(UITabBarController *)vc selectedViewController]];
  360. // } else {
  361. // return vc;
  362. // }
  363. //}
  364. //
  365. //- (void)initTimerWithSecound:(CGFloat)second {
  366. // //2.设置时间等
  367. // /*
  368. // 第一个参数:定时器对象
  369. // 第二个参数:DISPATCH_TIME_NOW 表示从现在开始计时
  370. // 第三个参数:间隔时间 GCD里面的时间最小单位为 纳秒
  371. // 第四个参数:精准度(表示允许的误差,0表示绝对精准)
  372. // */
  373. // dispatch_source_set_timer(self.myTimer, DISPATCH_TIME_NOW, second * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
  374. //
  375. // //3.要调用的任务
  376. // dispatch_source_set_event_handler(self.myTimer, ^{
  377. // NSLog(@"GCD-----%@",[NSThread currentThread]);
  378. //// [self.bannerAdManager loadNativeAd];
  379. //// if (![[self getCurrentVC] isKindOfClass:[ExerciseVC class]]) {
  380. //// NSLog(@"%s",object_getClassName([self getCurrentVC]));
  381. //// [self stopTimer];
  382. //// }
  383. // });
  384. //}
  385. //
  386. //- (void)pauseTimer {
  387. // if (self.myTimer) {
  388. // dispatch_suspend(_myTimer);
  389. // }
  390. //}
  391. //
  392. //- (void)resumeTimer {
  393. // if (_myTimer) {
  394. // dispatch_resume(_myTimer);
  395. // self.isResume = YES;
  396. // }
  397. //}
  398. //
  399. //- (void)stopTimer {
  400. // self.isResume = NO;
  401. // if (_myTimer) {
  402. // dispatch_source_cancel(_myTimer);
  403. // _myTimer = nil;
  404. // }
  405. //}
  406. //
  407. //
  408. //#pragma mark - ADSuyiSDKSplashAdDelegate
  409. ///**
  410. // 开屏展现成功
  411. //
  412. // @param splashAd 广告实例
  413. // */
  414. //- (void)adsy_splashAdSuccessToPresentScreen:(ADSuyiSDKSplashAd *)splashAd{
  415. //#ifdef SUPPORT_SPLASH_ZOOMOUT
  416. // if(splashAd.splashZoomOutView) {
  417. // UIViewController *rootVc = [UIApplication sharedApplication].keyWindow.rootViewController;
  418. // [rootVc.view addSubview:splashAd.splashZoomOutView];
  419. // }
  420. //#endif
  421. //}
  422. //
  423. ///**
  424. // 开屏展现失败
  425. //
  426. // @param splashAd 广告实例
  427. // @param error 具体错误信息
  428. // */
  429. //- (void)adsy_splashAdFailToPresentScreen:(ADSuyiSDKSplashAd *)splashAd failToPresentScreen:(ADSuyiAdapterErrorDefine *)error{
  430. // _splashAd = nil;
  431. //}
  432. //
  433. ///**
  434. // 开屏广告点击
  435. //
  436. // @param splashAd 广告实例
  437. // */
  438. //- (void)adsy_splashAdClicked:(ADSuyiSDKSplashAd *)splashAd{
  439. //
  440. //}
  441. //
  442. ///**
  443. // 开屏被关闭
  444. //
  445. // @param splashAd 广告实例
  446. // */
  447. //- (void)adsy_splashAdClosed:(ADSuyiSDKSplashAd *)splashAd{
  448. //#ifdef SUPPORT_SPLASH_ZOOMOUT
  449. // if(_splashAd.splashZoomOutView == nil)
  450. // _splashAd = nil;
  451. //#else
  452. // _splashAd = nil;
  453. //#endif
  454. //}
  455. //
  456. ///**
  457. // 开屏展示
  458. //
  459. // @param splashAd 广告实例
  460. // */
  461. //- (void)adsy_splashAdEffective:(ADSuyiSDKSplashAd *)splashAd{
  462. //
  463. //}
  464. //
  465. //#ifdef SUPPORT_SPLASH_ZOOMOUT
  466. //
  467. //#pragma mark - ADSuyiSDKSplashAdZoomOutViewDelegate
  468. //
  469. ///**
  470. // ZoomOutView被点击
  471. //
  472. // @param splashAd 广告实例
  473. // @param splashZoomOutView zoomOutView
  474. // */
  475. //- (void)adsy_splashZoomOutViewDidClick:(ADSuyiSDKSplashAd *)splashAd
  476. // splashZoomOutView:(__kindof UIView <ADSuyiSDKSplashAdZoomOutViewProtocol>*)splashZoomOutView {
  477. //
  478. //}
  479. //
  480. ///**
  481. // ZoomOutView 被关闭
  482. //
  483. // @param splashAd 广告实例
  484. // @param splashZoomOutView zoomOutView
  485. // */
  486. //- (void)adsy_splashZoomOutViewAdDidClose:(ADSuyiSDKSplashAd *)splashAd
  487. // splashZoomOutView:(__kindof UIView <ADSuyiSDKSplashAdZoomOutViewProtocol>*)splashZoomOutView {
  488. //
  489. //}
  490. //
  491. ///**
  492. // ZoomOutView 播放完成
  493. //
  494. // @param splashAd 广告实例
  495. // @param splashZoomOutView zoomOutView
  496. // */
  497. //- (void)adsy_splashZoomOutViewAdVideoFinished:(ADSuyiSDKSplashAd *)splashAd
  498. // splashZoomOutView:(__kindof UIView <ADSuyiSDKSplashAdZoomOutViewProtocol>*)splashZoomOutView {
  499. //
  500. //}
  501. //
  502. ///**
  503. // ZoomOutView 进入视频详情页
  504. //
  505. // @param splashAd 广告实例
  506. // @param splashZoomOutView zoomOutView
  507. // */
  508. //- (void)adsy_splashZoomOutViewAdDidPresentFullScreenModal:(ADSuyiSDKSplashAd *)splashAd
  509. // splashZoomOutView:(__kindof UIView <ADSuyiSDKSplashAdZoomOutViewProtocol>*)splashZoomOutView {
  510. //
  511. //}
  512. //
  513. ///**
  514. // ZoomOutView 退出视频详情页
  515. //
  516. // @param splashAd 广告实例
  517. // @param splashZoomOutView zoomOutView
  518. // */
  519. //- (void)adsy_splashZoomOutViewAdDidDismissFullScreenModal:(ADSuyiSDKSplashAd *)splashAd
  520. // splashZoomOutView:(__kindof UIView <ADSuyiSDKSplashAdZoomOutViewProtocol>*)splashZoomOutView {
  521. // _splashAd = nil;
  522. //}
  523. //
  524. //#endif
  525. //
  526. //
  527. //#pragma mark - ADSuyiSDKBannerAdViewDelegate
  528. ///**
  529. // 广告获取成功
  530. //
  531. // @param bannerView banner实例
  532. // */
  533. //- (void)adsy_bannerViewDidReceived:(ADSuyiSDKBannerAdView *)bannerView{
  534. // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Success) : nil;
  535. //}
  536. //
  537. ///**
  538. // 广告拉取失败
  539. //
  540. // @param bannerView banner实例
  541. // @param errorModel 错误描述
  542. // */
  543. //- (void)adsy_bannerViewFailToReceived:(ADSuyiSDKBannerAdView *)bannerView errorModel:(ADSuyiAdapterErrorDefine *)errorModel{
  544. // NSLog(@"adsy_bannerViewFailToReceived:%@, %@",errorModel.errorDescription, errorModel.errorDetailDict);
  545. // [self removeBanner];
  546. // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Faild) : nil;
  547. //}
  548. //
  549. ///**
  550. // 广告点击
  551. //
  552. // @param bannerView 广告实例
  553. // */
  554. //- (void)adsy_bannerViewClicked:(ADSuyiSDKBannerAdView *)bannerView{
  555. //
  556. //}
  557. //
  558. ///**
  559. // 广告关闭
  560. //
  561. // @param bannerView 广告实例
  562. // */
  563. //- (void)adsy_bannerViewClose:(ADSuyiSDKBannerAdView *)bannerView{
  564. // [self removeBanner];
  565. // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Close) : nil;
  566. //}
  567. //
  568. ///**
  569. // 广告展示
  570. //
  571. // @param bannerView 广告实例
  572. // */
  573. //- (void)adsy_bannerViewExposure:(ADSuyiSDKBannerAdView *)bannerView{
  574. //
  575. //}
  576. //
  577. //#pragma mark - ADSuyiSDKNativeAdDelegate
  578. //
  579. //- (void)adsy_nativeAdSucessToLoad:(ADSuyiSDKNativeAd *)nativeAd
  580. // adViewArray:(NSArray<__kindof UIView<ADSuyiAdapterNativeAdViewDelegate> *> *)adViewArray {
  581. // for (UIView<ADSuyiAdapterNativeAdViewDelegate> *adView in adViewArray) {
  582. // // 4、判断信息流广告是否为自渲染类型(可选实现) 可仿照所示样式demo实现 如无所需样式则需自行实现
  583. // // 如果单纯只配置了模版信息流,那么不需要实现,如果配置了自渲染信息流,那么需要实现
  584. // if(adView.renderType == ADSuyiAdapterRenderTypeNative) {
  585. // // 4.1、如果是自渲染类型则可样式自定义(3种示例demo样式见下)
  586. // // 1、常规样式
  587. //// [self setUpUnifiedTopImageNativeAdView:adView];
  588. // // 2、纯图样式
  589. // [self setUpUnifiedOnlyImageNativeAdView:adView];
  590. // // 3、上图下文
  591. //// [self setUpUnifiedTopImageNativeAdView:adView];
  592. // }
  593. // // 5、注册,自渲染:注册点击事件,模板:render,重要
  594. // [adView adsy_registViews:@[adView]];
  595. //
  596. // // 广点通视频信息流广告会给mediaView添加事件,点击会出现半屏广告,以下为广点通官方给予的解决方案
  597. // if([adView.adsy_platform isEqualToString:ADSuyiAdapterPlatformGDT]
  598. // && adView.renderType == ADSuyiAdapterRenderTypeNative
  599. // && adView.data.shouldShowMediaView) {
  600. // UIView *mediaView = [adView adsy_mediaViewForWidth:0.0];
  601. // mediaView.userInteractionEnabled = NO;
  602. // }
  603. // }
  604. //}
  605. //
  606. //- (void)adsy_nativeAdFailToLoad:(ADSuyiSDKNativeAd *)nativeAd
  607. // errorModel:(ADSuyiAdapterErrorDefine *)errorModel {
  608. // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Faild) : nil;
  609. //}
  610. //- (void)adsy_nativeAdViewRenderOrRegistSuccess:(UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
  611. // self.currentAdView = adView;
  612. // [self.customView addSubview:self.currentAdView];
  613. //
  614. //}
  615. //- (void)adsy_nativeAdViewRenderOrRegistFail:(UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
  616. // self.currentAdView = adView;
  617. // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Faild) : nil;
  618. //}
  619. //- (void)adsy_nativeAdClicked:(ADSuyiSDKNativeAd *)nativeAd
  620. // adView:(__kindof UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
  621. // self.currentAdView = adView;
  622. // [adView adsy_close];
  623. //}
  624. //- (void)adsy_nativeAdClose:(ADSuyiSDKNativeAd *)nativeAd
  625. // adView:(__kindof UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
  626. // if (self.currentAdView) {
  627. // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Close) : nil;
  628. // self.currentAdView = adView;
  629. // [self.currentAdView removeFromSuperview];
  630. // [self.skipBtn removeFromSuperview];
  631. // self.currentAdView = nil;
  632. // self.nativeAd = nil;
  633. // }
  634. //}
  635. //- (void)adsy_nativeAdExposure:(ADSuyiSDKNativeAd *)nativeAd
  636. // adView:(__kindof UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
  637. // self.currentAdView = adView;
  638. // [self.customView bringSubviewToFront:self.skipBtn];
  639. // self.count = 5;
  640. // [_skipBtn setTitleNormal:@"跳过 5"];
  641. // self.timer = [YYTimer timerWithTimeInterval:1 target:self selector:@selector(_timerValueChanged:) repeats:YES];
  642. // self.aDCloseCompletedBlock? self.aDCloseCompletedBlock(RQADDoType_Success) : nil;
  643. //}
  644. //
  645. //#pragma mark - Helper 自渲染类型信息流处理方法 setUpUnifiedOnlyImageNativeAdView纯图样式
  646. //// 纯图样式
  647. //- (void)setUpUnifiedOnlyImageNativeAdView:(UIView<ADSuyiAdapterNativeAdViewDelegate> *)adView {
  648. // // 设计的adView实际大小,其中宽度和高度可以自己根据自己的需求设置
  649. // CGFloat adWidth = self.customView.frame.size.width;
  650. // CGFloat adHeight = adWidth / 16.0 * 9;
  651. // adView.frame = CGRectMake(0, 0, adWidth, adHeight);
  652. //
  653. // // 设置主图/视频(主图可选,但强烈建议带上,如果有视频试图,则必须带上)
  654. // CGRect mainFrame = CGRectMake(0, 0, adWidth, adHeight);
  655. // if(adView.data.shouldShowMediaView) {
  656. // UIView *mediaView = [adView adsy_mediaViewForWidth:mainFrame.size.width];
  657. // mediaView.frame = mainFrame;
  658. // [adView addSubview:mediaView];
  659. // } else {
  660. // UIImageView *imageView = [UIImageView new];
  661. // imageView.backgroundColor = [UIColor adsy_colorWithHexString:@"#CCCCCC"];
  662. // [adView addSubview:imageView];
  663. // imageView.frame = mainFrame;
  664. // NSString *urlStr = adView.data.imageUrl;
  665. // if(urlStr.length > 0) {
  666. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
  667. // UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlStr]]];
  668. // dispatch_async(dispatch_get_main_queue(), ^{
  669. // imageView.image = image;
  670. // });
  671. // });
  672. // }
  673. // }
  674. //
  675. // // 展示关闭按钮(必要)
  676. // [self.customView addSubview:self.skipBtn];
  677. // self.skipBtn.frame = CGRectMake(adWidth - 12 - 54, 12, 54, 27);
  678. // [self.skipBtn addTarget:adView action:@selector(adsy_close) forControlEvents:UIControlEventTouchUpInside];
  679. //
  680. // // 显示logo图片(必要)
  681. // if(![adView.adsy_platform isEqualToString:ADSuyiAdapterPlatformGDT]) { // 优量汇(广点通)会自带logo,不需要添加
  682. // UIImageView *logoImage = [UIImageView new];
  683. // [adView addSubview:logoImage];
  684. //// [adView bringSubviewToFront:logoImage];
  685. // [adView adsy_platformLogoImageDarkMode:NO loadImageBlock:^(UIImage * _Nullable image) {
  686. // CGFloat maxWidth = 40;
  687. // CGFloat logoHeight = maxWidth / image.size.width * image.size.height;
  688. // logoImage.frame = CGRectMake(adWidth - maxWidth, adHeight - logoHeight, maxWidth, logoHeight);
  689. // logoImage.image = image;
  690. // }];
  691. // }
  692. //}
  693. //
  694. //#pragma mark - ADSuyiSDKIntertitialAdDelegate
  695. ///**
  696. // ADSuyiSDKIntertitialAd请求成功回调
  697. //
  698. // @param interstitialAd 插屏广告实例对象
  699. //*/
  700. //- (void)adsy_interstitialAdSuccedToLoad:(ADSuyiSDKIntertitialAd *)interstitialAd {
  701. // self.isReady = YES;
  702. // if (!RQ_Video_Module.playerController.isPlaying && self.adType == RQADType_fullScreen && self.isCanShow && _fullScreenvodAd) {
  703. // [_fullScreenvodAd show];
  704. // }
  705. //}
  706. //
  707. ///**
  708. // ADSuyiSDKIntertitialAd请求失败回调
  709. //
  710. // @param interstitialAd 插屏广告实例对象
  711. // @param error 失败原因
  712. //*/
  713. //- (void)adsy_interstitialAdFailedToLoad:(ADSuyiSDKIntertitialAd *)interstitialAd error:(ADSuyiAdapterErrorDefine *)error {
  714. // _fullScreenvodAd = nil;
  715. //}
  716. //
  717. ///**
  718. // ADSuyiSDKIntertitialAd展示在屏幕内回调
  719. //
  720. // @param interstitialAd 插屏广告实例对象
  721. //*/
  722. //- (void)adsy_interstitialAdDidPresent:(ADSuyiSDKIntertitialAd *)interstitialAd {
  723. //
  724. //}
  725. //
  726. ///**
  727. // ADSuyiSDKIntertitialAd展示在屏幕内失败回调
  728. //
  729. // @param interstitialAd 插屏广告实例对象
  730. //*/
  731. //- (void)adsy_interstitialAdFailedToPresent:(ADSuyiSDKIntertitialAd *)interstitialAd error:(NSError *)error {
  732. //
  733. //}
  734. //
  735. ///**
  736. // ADSuyiSDKIntertitialAd点击回调
  737. //
  738. // @param interstitialAd 插屏广告实例对象
  739. //*/
  740. //- (void)adsy_interstitialAdDidClick:(ADSuyiSDKIntertitialAd *)interstitialAd {
  741. //
  742. //}
  743. //
  744. ///**
  745. // ADSuyiSDKIntertitialAd关闭回调
  746. //
  747. // @param interstitialAd 插屏广告实例对象
  748. //*/
  749. //- (void)adsy_interstitialAdDidClose:(ADSuyiSDKIntertitialAd *)interstitialAd {
  750. //
  751. //}
  752. //
  753. ///**
  754. // ADSuyiSDKIntertitialAd展示回调
  755. //
  756. // @param interstitialAd 广告实例
  757. // */
  758. //- (void)adsy_interstitialAdExposure:(ADSuyiSDKIntertitialAd *)interstitialAd {
  759. //
  760. //}
  761. //
  762. //#pragma mark - LazyLoad
  763. //- (dispatch_source_t)myTimer {
  764. // if (!_myTimer) {
  765. // //0.创建队列
  766. // dispatch_queue_t queue = dispatch_get_main_queue();
  767. // //1.创建GCD中的定时器
  768. // /*
  769. // 第一个参数:创建source的类型 DISPATCH_SOURCE_TYPE_TIMER:定时器
  770. // 第二个参数:0
  771. // 第三个参数:0
  772. // 第四个参数:队列
  773. // */
  774. // _myTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
  775. // }
  776. // return _myTimer;
  777. //}
  778. //
  779. //- (UIView *)customView {
  780. // if (!_customView) {
  781. // CGRect rect;
  782. // switch (self.adType) {
  783. // case RQADType_Splash:
  784. // rect = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT * 0.75);
  785. // break;
  786. // case RQADType_Banner:
  787. // rect = CGRectMake(25, (RQ_SCREEN_HEIGHT - RQ_APPLICATION_TOP_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT) - 60 - 40, RQ_SCREEN_WIDTH - 50, 50);
  788. // default:
  789. // rect = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT);
  790. // break;
  791. // }
  792. // _customView = [[UIView alloc] initWithFrame:rect];
  793. // }
  794. // return _customView;
  795. //}
  796. //
  797. //- (ADSuyiSDKBannerAdView *)bannerView {
  798. // if (!_bannerView) {
  799. // // 1、初始化banner视图,并给定frame值,rate取值根据banner的尺寸
  800. // _bannerView = [[ADSuyiSDKBannerAdView alloc] initWithFrame:CGRectMake(0, 0, self.customView.width, self.customView.height)];
  801. // _bannerView.delegate = self;
  802. // // 2、设置控制器,用来弹出落地页,重要
  803. // _bannerView.controller = self.customViewController;
  804. // // 3、设置广告位id,重要
  805. // CGFloat a = RQ_SCREEN_WIDTH / (640/100.0);
  806. // if (self.customView.height > a) {
  807. // _bannerView.posId = bannerPlcId2;
  808. // } else {
  809. // _bannerView.posId = bannerPlcId;
  810. // }
  811. // // 可设置bannerview的背景色,请按需添加修改该行代码
  812. // _bannerView.backgroundColor = UIColor.whiteColor;
  813. // }
  814. // return _bannerView;
  815. //}
  816. //
  817. //- (ADSuyiSDKNativeAd *)nativeAd {
  818. // if (!_nativeAd) {
  819. // _nativeAd = [[ADSuyiSDKNativeAd alloc] initWithAdSize:self.customView.size];
  820. // _nativeAd.delegate = self;
  821. // _nativeAd.controller = RQControllerHelper.currentViewController;
  822. // _nativeAd.posId = nativeAdPlcId;
  823. // }
  824. // return _nativeAd;
  825. //}
  826. //
  827. //- (ADSuyiSDKIntertitialAd *)fullScreenvodAd {
  828. // if (!_fullScreenvodAd) {
  829. // _fullScreenvodAd = [ADSuyiSDKIntertitialAd new];
  830. // UIViewController *vc = RQControllerHelper.currentViewController;
  831. // _fullScreenvodAd.controller = vc;
  832. // _fullScreenvodAd.posId = fullScreenvodAdPlcId;
  833. // _fullScreenvodAd.delegate = self;
  834. // _fullScreenvodAd.tolerateTimeout = 4;
  835. // _fullScreenvodAd.adSize = CGSizeMake(vc.view.frame.size.width, vc.view.frame.size.height);
  836. // }
  837. // return _fullScreenvodAd;
  838. //}
  839. //
  840. //- (UIButton *)skipBtn {
  841. // if (!_skipBtn) {
  842. // _skipBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  843. // _skipBtn.frame = CGRectMake(RQ_SCREEN_WIDTH - 54 - 12, 12, 54, 27);
  844. // [_skipBtn setBackgroundColor:[UIColor colorWithWhite:0.1 alpha:0.3]];
  845. //// [_skipBtn setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithWhite:0.1 alpha:1] size:CGSizeMake(200, 200)] forState:UIControlStateNormal];
  846. // _skipBtn.titleLabel.font = RQRegularFont(13);
  847. // [_skipBtn setTitleNormal:@"跳过 5"];
  848. // _skipBtn.layer.cornerRadius = 13.5;
  849. // _skipBtn.clipsToBounds = YES;
  850. // }
  851. // return _skipBtn;
  852. //}
  853. //@end