APPdelegateModularForCustomMethod.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // APPdelegateModularForCustomMethod.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2019/3/26.
  6. // Copyright © 2019 JCZ. All rights reserved.
  7. //
  8. #import "APPdelegateModularForCustomMethod.h"
  9. #import "RQAppEventAnnotation.h"
  10. RQAppEventMod(APPdelegateModularForCustomMethod)
  11. @implementation APPdelegateModularForCustomMethod
  12. - (NSInteger)moduleLevel {
  13. return 6;
  14. }
  15. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  16. [self initMudule];
  17. // [self destroyModule];
  18. return YES;
  19. }
  20. - (void)initMudule {
  21. /// 启动页广告
  22. if (!RQ_SHARE_FUNCTION.APP_AD && !myDelegate.adIsShow) {
  23. [self initBeginAD];
  24. myDelegate.adIsShow = YES;
  25. }
  26. }
  27. #pragma mark - 启动页广告
  28. - (void)initBeginAD {
  29. //初始化开屏广告
  30. [self setupXHLaunchAd];
  31. }
  32. -(void)setupXHLaunchAd{
  33. //******图片开屏广告 - 本地数据******
  34. [self example];
  35. }
  36. #pragma mark - 图片开屏广告-本地数据-示例
  37. //图片开屏广告 - 本地数据
  38. - (void)example {
  39. //设置你工程的启动页使用的是:LaunchImage 还是 LaunchScreen.storyboard(不设置默认:LaunchImage)
  40. [XHLaunchAd setLaunchSourceType:SourceTypeLaunchScreen];
  41. [XHLaunchAd setWaitDataDuration:0];
  42. //配置广告数据
  43. XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration new];
  44. //广告停留时间
  45. imageAdconfiguration.duration = 5;
  46. //广告frame
  47. imageAdconfiguration.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
  48. //广告图片URLString/或本地图片名(.jpg/.gif请带上后缀)
  49. NSString *path = @"";
  50. if (!defUser.adPaths || defUser.adPaths.count <1) {
  51. }else{
  52. path = defUser.adPaths[arc4random()%defUser.adPaths.count];
  53. }
  54. imageAdconfiguration.imageNameOrURLString = [path isEqualToString:@""]? @"firstAD.jpg" : path;
  55. imageAdconfiguration.imageOption = XHLaunchAdImageCacheInBackground;
  56. //图片填充模式
  57. imageAdconfiguration.contentMode = UIViewContentModeScaleToFill;
  58. //广告显示完成动画
  59. imageAdconfiguration.showFinishAnimate = ShowFinishAnimateFadein;
  60. //广告显示完成动画时间
  61. imageAdconfiguration.showFinishAnimateTime = 0.8;
  62. //跳过按钮类型
  63. imageAdconfiguration.skipButtonType = SkipTypeRoundProgressTime;
  64. //后台返回时,是否显示广告
  65. imageAdconfiguration.showEnterForeground = NO;
  66. //显示开屏广告
  67. [XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:nil];
  68. }
  69. /// 应用处于后台,所有下载任务完成调用
  70. - (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)(void))completionHandler {
  71. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  72. appDelegate.backgroundSessionCompletionHandler = completionHandler;
  73. }
  74. /// 程序意外退出
  75. - (void)applicationWillTerminate:(UIApplication *)application {
  76. //NSLog(@"程序退出"); 程序退出要将登录状态置为未登录状态
  77. }
  78. /// 程序进入后台
  79. - (void)applicationDidEnterBackground:(UIApplication *)application {
  80. /// 实现如下代码,才能使程序处于后台时被杀死,调用applicationWillTerminate:方法
  81. [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^(){}];
  82. }
  83. /// 程序进入前台
  84. - (void)applicationDidBecomeActive:(UIApplication *)application {
  85. /// 检查版本更新
  86. if (defUser.qzgx == 1) {
  87. [RQ_SHARE_FUNCTION checkVersion];
  88. }
  89. }
  90. #pragma mark - 深色模式
  91. //- (void)initDarkModle API_AVAILABLE(ios(13.0)) {
  92. // [RACObserve(RQ_SHARE_FUNCTION, currentUserInterfaceStyle) subscribeNext:^(id _Nullable x) {
  93. // if (@available(iOS 13.0, *)) {
  94. // dispatch_async(dispatch_get_main_queue(), ^{
  95. // [UIApplication sharedApplication].keyWindow.overrideUserInterfaceStyle = RQ_SHARE_FUNCTION.currentUserInterfaceStyle;
  96. // });
  97. // } else {
  98. // // Fallback on earlier versions
  99. // }
  100. // }];
  101. //}
  102. @end