123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- //
- // APPdelegateModularForCustomMethod.m
- // jiaPei
- //
- // Created by 张嵘 on 2019/3/26.
- // Copyright © 2019 JCZ. All rights reserved.
- //
- #import "APPdelegateModularForCustomMethod.h"
- #import "RQAppEventAnnotation.h"
- RQAppEventMod(APPdelegateModularForCustomMethod)
- @implementation APPdelegateModularForCustomMethod
- - (NSInteger)moduleLevel {
- return 6;
- }
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- [self initMudule];
- // [self destroyModule];
- return YES;
- }
- - (void)initMudule {
- /// 启动页广告
- if (!RQ_SHARE_FUNCTION.APP_AD && !myDelegate.adIsShow) {
- [self initBeginAD];
- myDelegate.adIsShow = YES;
- }
- }
- #pragma mark - 启动页广告
- - (void)initBeginAD {
- //初始化开屏广告
- [self setupXHLaunchAd];
- }
- -(void)setupXHLaunchAd{
- //******图片开屏广告 - 本地数据******
- [self example];
- }
- #pragma mark - 图片开屏广告-本地数据-示例
- //图片开屏广告 - 本地数据
- - (void)example {
- //设置你工程的启动页使用的是:LaunchImage 还是 LaunchScreen.storyboard(不设置默认:LaunchImage)
- [XHLaunchAd setLaunchSourceType:SourceTypeLaunchScreen];
- [XHLaunchAd setWaitDataDuration:0];
-
- //配置广告数据
- XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration new];
- //广告停留时间
- imageAdconfiguration.duration = 5;
- //广告frame
- imageAdconfiguration.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
- //广告图片URLString/或本地图片名(.jpg/.gif请带上后缀)
- NSString *path = @"";
- if (!defUser.adPaths || defUser.adPaths.count <1) {
- }else{
- path = defUser.adPaths[arc4random()%defUser.adPaths.count];
- }
- imageAdconfiguration.imageNameOrURLString = [path isEqualToString:@""]? @"firstAD.jpg" : path;
- imageAdconfiguration.imageOption = XHLaunchAdImageCacheInBackground;
- //图片填充模式
- imageAdconfiguration.contentMode = UIViewContentModeScaleToFill;
- //广告显示完成动画
- imageAdconfiguration.showFinishAnimate = ShowFinishAnimateFadein;
- //广告显示完成动画时间
- imageAdconfiguration.showFinishAnimateTime = 0.8;
- //跳过按钮类型
- imageAdconfiguration.skipButtonType = SkipTypeRoundProgressTime;
- //后台返回时,是否显示广告
- imageAdconfiguration.showEnterForeground = NO;
- //显示开屏广告
- [XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:nil];
- }
- /// 应用处于后台,所有下载任务完成调用
- - (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)(void))completionHandler {
- AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- appDelegate.backgroundSessionCompletionHandler = completionHandler;
- }
- /// 程序意外退出
- - (void)applicationWillTerminate:(UIApplication *)application {
- //NSLog(@"程序退出"); 程序退出要将登录状态置为未登录状态
- }
- /// 程序进入后台
- - (void)applicationDidEnterBackground:(UIApplication *)application {
- /// 实现如下代码,才能使程序处于后台时被杀死,调用applicationWillTerminate:方法
- [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^(){}];
- }
- /// 程序进入前台
- - (void)applicationDidBecomeActive:(UIApplication *)application {
- /// 检查版本更新
- if (defUser.qzgx == 1) {
- [RQ_SHARE_FUNCTION checkVersion];
- }
- }
- #pragma mark - 深色模式
- //- (void)initDarkModle API_AVAILABLE(ios(13.0)) {
- // [RACObserve(RQ_SHARE_FUNCTION, currentUserInterfaceStyle) subscribeNext:^(id _Nullable x) {
- // if (@available(iOS 13.0, *)) {
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [UIApplication sharedApplication].keyWindow.overrideUserInterfaceStyle = RQ_SHARE_FUNCTION.currentUserInterfaceStyle;
- // });
- // } else {
- // // Fallback on earlier versions
- // }
- // }];
- //}
- @end
|