123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- //
- // APPdelegateModularForRequest.m
- // jiaPei
- //
- // Created by 张嵘 on 2021/4/12.
- // Copyright © 2021 JCZ. All rights reserved.
- //
- #import "APPdelegateModularForRequest.h"
- #import "RQAppEventAnnotation.h"
- RQAppEventMod(APPdelegateModularForRequest)
- @implementation APPdelegateModularForRequest
- - (NSInteger)moduleLevel {
- return 1;
- }
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- [self initMudule];
- // [self destroyModule];
- return YES;
- }
- - (void)initMudule {
- /// 获取广告相关
- [self getAppParam];
- /// 视频接口相关
- [self getVideoTypeList];
- /// 同步本地数据
- [UserInfo shareInfo];
-
- [self getConfigKey];
-
- if (RQ_USER_MANAGER.currentUser) {
- myDelegate.isLogin = YES;
- }
-
- //默认科目一
- if (!myDelegate.subject) {
- myDelegate.subject = @"1";
- RQ_YDTQuestion_Module.subject = RQHomePageSubjectType_SubjectOne;
- }
-
- //异步获取新的广告
- [jiaPeiManager requestADImage];
-
- //判断跳转页面 这样每次更新版本 都会有导航页
- NSString *vesionNow = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
-
- // if (![RQ_COMMON_MANAGER.isWelcomed isEqualToString:vesionNow]) {
- // [[NSUserDefaults standardUserDefaults] setBool:NO forKey:BOOLFORKEY];
- // RQ_COMMON_MANAGER.isWelcomed = vesionNow;
- // //如果更新了数据库 运行的时候要加上下面这句代码 提取旧库数据 移除旧的数据库 重新copy到document文件目录下
- // [DB_Que_Helper getDataFormLastDB];
- // myDelegate.isSyn = YES;
- // } else {
- //
- // }
- }
- - (void)getAppParam {
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"dqbh" Value:[NSString stringWithFormat:@"%@",RQ_USER_MANAGER.currentUser.city? : ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"(null)"]? @"" : @"")]];
- NSString *method= @"getAppParam";
-
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
- if ([dict[@"code"] isEqualToString:@"0"]) {
- if ([dict [@"body"] isKindOfClass:[NSArray class]]) {
- NSArray *array = dict [@"body"];
- [array.rac_sequence.signal subscribeNext:^(NSDictionary *dic) {
- [RQ_SHARE_FUNCTION saveObjectWithObject:dic[@"VALUE"] ForKey:dic[@"KEY"]];
- }];
- }
- }
- }];
- }
- - (void)getVideoTypeList {
- [[RQ_HTTP_Service getTreeList] subscribeNext:^(NSArray <RQTreeListModel *> * dataArr) {
- if (!RQObjectIsNil(dataArr)) {
- RQ_COMMON_MANAGER.treeListArr = dataArr;
- }
- }];
-
- [[RQ_HTTP_Service getDspListWithPageNum:1 pageSize:10] subscribeNext:^(NSArray <VideosItem *> * videosItemArr) {
- if (!RQObjectIsNil(videosItemArr)) {
- RQ_COMMON_MANAGER.dspListArr = videosItemArr;
- }
- }];
-
-
- }
- - (void)getAppStoreVersionWithComplete:(VoidBlock_integer)complete {
- NSString *URL = @"http://itunes.apple.com/cn/lookup?id=1214200225";
- NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:URL] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];
- [request setHTTPMethod:@"POST"];
- NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
- dispatch_async_on_main_queue(^{
- //这个导致部分手机网络不好时候出现闪退情况
- if (!data) {
- complete(0);
- return;
- }
- //如果data等于nil的时候 再去解析 会发生崩溃
- NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
-
- if (!dic) {
- complete(0);
- return;
- }
- NSArray *infoArray = [dic objectForKey:@"results"];
- if ([infoArray count]) {
- NSDictionary *releaseInfo = [infoArray objectAtIndex:0];
- NSString *netVersion = [releaseInfo objectForKey:@"version"];
- // 线上版本号
- NSInteger netInt = [[netVersion stringByReplacingOccurrencesOfString:@"." withString:@""] integerValue];
- complete(netInt);
- } else {
- complete(0);
- }
- });
- }];
-
- [task resume];
- }
- - (void)getConfigKey {
- NSInteger localVersion = [[RQ_APP_VERSION stringByReplacingOccurrencesOfString:@"." withString:@""] integerValue];
- [[RQ_HTTP_Service getJsjpSet] subscribeNext:^(NSArray *setArr) {
- [setArr.rac_sequence.signal subscribeNext:^(RQDictInfoModel *dictInfoModel) {
- if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_APP_AD_OPEN"]) {
- RQ_COMMON_MANAGER.JSJP_APP_AD_OPEN = [[NSString stringWithFormat:@"%@",dictInfoModel.dictValue] isEqualToString:@"1"]? YES : NO;
- }else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_APP_JSQ_ICON_OPEN"]) {
- RQ_COMMON_MANAGER.JSJP_APP_JSQ_ICON_OPEN = [[NSString stringWithFormat:@"%@",dictInfoModel.dictValue] isEqualToString:@"1"]? YES : NO;
- }else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_APP_VOICE"]) {
- RQ_COMMON_MANAGER.JSJP_APP_VOICE = [[NSString stringWithFormat:@"%@",dictInfoModel.dictValue] isEqualToString:@"1"]? YES : NO;
- }else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_APP_VOICE_SET"]) {
- NSError *error = nil;
- // Convert JSON string to NSDictionary
- NSData *jsonData = [dictInfoModel.dictValue dataUsingEncoding:NSUTF8StringEncoding];
- NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];
- RQ_COMMON_MANAGER.JSJP_APP_VOICE_SET = jsonDictionary;
- }else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_APP_XM_AD_RATE"]) {
- RQ_COMMON_MANAGER.JSJP_APP_XM_AD_RATE = [dictInfoModel.dictValue integerValue];
- }else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_APP_AD_CYCLE"]) {
- RQ_COMMON_MANAGER.JSJP_APP_AD_CYCLE = [dictInfoModel.dictValue integerValue];
- } else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_iOS_PT"]) {
- RQ_COMMON_MANAGER.JSJP_iOS_PT = [dictInfoModel.dictValue integerValue];
- } else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_SHARE_CITY"]) {
- RQ_COMMON_MANAGER.JSJP_SHARE_CITY = dictInfoModel.dictValue;
- }else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_XCX_NAME"]) {
- RQ_COMMON_MANAGER.JSJP_XCX_NAME = dictInfoModel.dictValue;
- }else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_XCX_PAGE"]) {
- RQ_COMMON_MANAGER.JSJP_XCX_PAGE = dictInfoModel.dictValue;
- }else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_Is_Online_Media_Image"]) {
- RQ_COMMON_MANAGER.JSJP_Is_Online_Media_Image = [dictInfoModel.dictValue boolValue];
- } else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_Is_Online_Media_Video"]) {
- RQ_COMMON_MANAGER.JSJP_Is_Online_Media_Video = [dictInfoModel.dictValue boolValue];
- } else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_Online_Version"]) {
- NSInteger customOnlineVersion = [[[NSString stringWithFormat:@"%@",dictInfoModel.dictValue] stringByReplacingOccurrencesOfString:@"." withString:@""] integerValue];
- RQ_COMMON_MANAGER.APP_SWITCH = (localVersion > customOnlineVersion);
- } else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_APP_ICON_NEED_CHANGE"]) {
- RQ_COMMON_MANAGER.JSJP_APP_ICON_NEED_CHANGE = [dictInfoModel.dictValue boolValue];
- } else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_APP_AD_RATE"]) {
- RQ_COMMON_MANAGER.JSJP_APP_AD_RATE = [dictInfoModel.dictValue integerValue];
- } else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_APP_PTSC_FBL"]) {
- RQ_COMMON_MANAGER.JSJP_APP_PTSC_FBL = dictInfoModel.dictValue;
- } else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_DOMIAN_NAME_IS_OLD"]) {
- RQ_COMMON_MANAGER.JSJP_DOMIAN_NAME_IS_OLD = [dictInfoModel.dictValue boolValue];
- } else if ([dictInfoModel.dictLabel isEqualToString:@"JSJP_APP_KAOCHANG_OPEN_ARR"]) {
- RQ_COMMON_MANAGER.JSJP_APP_KAOCHANG_OPEN_ARR = [dictInfoModel.remark componentsSeparatedByString:@","];
- }
- }];
- }];
- [[RQ_HTTP_Service getChapterList] subscribeNext:^(id _Nullable x) {
-
- }];
-
- }
- @end
|