87 lines
3.1 KiB
Objective-C
87 lines
3.1 KiB
Objective-C
//
|
|
// DDClientConfig.m
|
|
// DingDangApp
|
|
//
|
|
// Created by 触海 on 2023/12/14.
|
|
//
|
|
|
|
#import "DDClientConfig.h"
|
|
#import "DDRequestTool.h"
|
|
#import "DDUtility.h"
|
|
#import "NSString+DDUtils.h"
|
|
|
|
@interface DDClientConfig() {
|
|
NSTimer *timer;
|
|
}
|
|
///重试的次数 10次 如果你还是失败的话 那就算了 没办法了
|
|
@property (nonatomic,assign) int retryCount;
|
|
@end
|
|
|
|
@implementation DDClientConfig
|
|
|
|
+ (instancetype)shareConfig {
|
|
static dispatch_once_t onceToken;
|
|
static DDClientConfig * config;
|
|
dispatch_once(&onceToken, ^{
|
|
config = [[DDClientConfig alloc] init];
|
|
});
|
|
return config;
|
|
}
|
|
|
|
- (void)clientInit {
|
|
NSDictionary *params = [NSDictionary dictionary];
|
|
/// /client/init
|
|
NSString *url = [DDEncryptManager dd_aesDecryptWithText:@"F4QHLrzw6NaFvemJzMLFhA=="];
|
|
[DDRequestTool DD_Request_POST:url params:params success:^(BaseModel * _Nonnull data) {
|
|
if (data.code == 200) {
|
|
self.retryCount = 0;
|
|
NSDictionary *initData = data.data;
|
|
self.iosPhoneBind = [initData[@"iosPhoneBind"] boolValue];
|
|
//糖果树配置
|
|
self.openCandyTree = [initData[@"openBoxSwitch"] boolValue];
|
|
self.openCandyTreeLimitLevel = [initData[@"openBoxSwitchLevelNo"] intValue];
|
|
DDClientModel * model = [DDClientModel DD_ModelWithDict:data.data];
|
|
self.configInfo = model;
|
|
//表情包
|
|
NSString *json = initData[@"faceJson"][@"json"];
|
|
// NSString *deJson = [DESEncrypt decryptUseDES:json key:KeyWithType(KeyType_FacePwdEncode)];
|
|
// NSDictionary *faceInitData = [deJson toJSONObject];
|
|
// model.faceInitData = faceInitData;
|
|
|
|
NSString *trtcAppId = [NSString stringWithFormat:@"%@",initData[@"trtcAppId"]];
|
|
NSString *curTtcKey = [[NSUserDefaults standardUserDefaults]valueForKey:@"kTrtcAppId"];
|
|
if(curTtcKey == nil){
|
|
if(trtcAppId != nil){
|
|
[[NSUserDefaults standardUserDefaults]setValue:trtcAppId forKey:@"kTrtcAppId"];
|
|
[[NSUserDefaults standardUserDefaults]synchronize];
|
|
}
|
|
}else{
|
|
if(![trtcAppId isEqualToString:curTtcKey]){
|
|
if(trtcAppId != nil){
|
|
[[NSUserDefaults standardUserDefaults]setValue:trtcAppId forKey:@"kTrtcAppId"];
|
|
[[NSUserDefaults standardUserDefaults]synchronize];
|
|
}
|
|
}
|
|
}
|
|
//是否展示公屏
|
|
NSString *serverVer = initData[@"appStoreAuditNoticeVersion"];
|
|
NSString *shortVer = [DDUtility DD_AppVersion];
|
|
BOOL isHigh = [NSString DD_VersionCompareOldString:serverVer newString:shortVer];
|
|
model.appStoreAuditNoticeVersion = isHigh;
|
|
model.appStoreAuditNoticeVersion = NO;
|
|
self.configInfo = model;
|
|
} else {
|
|
if (self.retryCount < 10) {
|
|
[self clientInit];
|
|
self.retryCount+=1;
|
|
}
|
|
}
|
|
|
|
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
|
|
[ToolsObject addPopVieToText:message];
|
|
}];
|
|
}
|
|
|
|
|
|
@end
|