Files
peko-ios/YuMi/Appdelegate/AppDelegate+ThirdConfig.m

210 lines
6.5 KiB
Mathematica
Raw Normal View History

2023-07-06 16:54:13 +08:00
//
// AppDelegate+ThirdConfig.m
// YUMI
//
// Created by YUMI on 2021/9/13.
//
#import "AppDelegate+ThirdConfig.h"
2023-07-14 18:50:55 +08:00
///Third
2023-07-06 16:54:13 +08:00
#import <NIMSDK/NIMSDK.h>
#import <ShareSDK/ShareSDK.h>
#import <UserNotifications/UNUserNotificationCenter.h>
2023-07-14 18:50:55 +08:00
///Tool
2023-07-06 16:54:13 +08:00
#import "YUMIConstant.h"
#import "CustomAttachmentDecoder.h"
2023-07-14 18:50:55 +08:00
#import "QEmotionHelper.h"
#import "XPAdvertiseView.h"
#import "XPAdImageTool.h"
2023-07-06 16:54:13 +08:00
#import "YUMIMacroUitls.h"
2023-07-14 18:50:55 +08:00
#import "AdvertiseModel.h"
#import "XPWebViewController.h"
#import "XPRoomViewController.h"
#import "XCCurrentVCStackManager.h"
#import "ClientConfig.h"
2023-08-08 11:26:07 +08:00
#import <Adjust/Adjust.h>
2023-07-06 16:54:13 +08:00
2023-08-14 14:45:44 +08:00
#import <Bugly/Bugly.h>
2023-08-11 14:46:56 +08:00
2023-07-06 16:54:13 +08:00
UIKIT_EXTERN NSString * kYouMiNumberCountKey;
UIKIT_EXTERN NSString * adImageName;
@implementation AppDelegate (ThirdConfig)
2023-07-14 18:50:55 +08:00
///
- (void)initThirdConfig {
[self configShareSDK];
[self configNIMSDK];
[self initEmojiData];
2023-08-08 11:26:07 +08:00
[self configAdjust];
2023-08-14 14:45:44 +08:00
[self configBugly];
2023-07-06 16:54:13 +08:00
}
2023-08-14 14:45:44 +08:00
/**
Bugly
*/
- (void) configBugly {
BuglyConfig *config = [[BuglyConfig alloc] init];
config.channel = @"App Enterprise";
config.blockMonitorEnable = YES; //
config.blockMonitorTimeout = 5;
config.unexpectedTerminatingDetectionEnable = YES; // 退
2023-07-06 16:54:13 +08:00
2023-08-14 14:45:44 +08:00
#ifdef DEBUG
config.debugMode = YES; // debug
config.reportLogLevel = BuglyLogLevelVerbose; //
[Bugly startWithAppId:@"86cf73b8d5" config:config];
#else
config.debugMode = NO; // release
config.reportLogLevel = BuglyLogLevelWarn; //
[Bugly startWithAppId:@"0fcba36f9a" config:config];
#endif
}
2023-07-14 18:50:55 +08:00
- (void)configNIMSDK {
// NIMSDK
NSString *appKey = KeyWithType(KeyType_NetEase);
2023-07-06 16:54:13 +08:00
NIMSDKOption *option = [NIMSDKOption optionWithAppKey:appKey];
[[NIMSDK sharedSDK] registerWithOption:option];
2023-07-14 18:50:55 +08:00
// NIM SDK
2023-07-06 16:54:13 +08:00
[NIMCustomObject registerCustomDecoder:[[CustomAttachmentDecoder alloc] init]];
[NIMSDKConfig sharedConfig].shouldConsiderRevokedMessageUnreadCount = YES;
2023-07-14 18:50:55 +08:00
///
2023-07-06 16:54:13 +08:00
[[NIMSDKConfig sharedConfig] setShouldSyncStickTopSessionInfos:YES];
#ifdef DEBUG
[NIMSDKConfig sharedConfig].enabledHttpsForInfo = NO;
[NIMSDKConfig sharedConfig].enabledHttpsForMessage = NO;
#endif
}
2023-08-08 11:26:07 +08:00
-(void)configAdjust{
NSString *appToken = @"p5sndfu9udq8";
NSString *environment;
#ifdef DEBUG
environment = ADJEnvironmentSandbox;
#else
environment = ADJEnvironmentProduction;
#endif
ADJConfig*adjustConfig = [ADJConfig configWithAppToken:appToken
environment:environment];
#ifdef DEBUG
[adjustConfig setLogLevel:ADJLogLevelVerbose];
#else
#endif
[Adjust appDidLaunch:adjustConfig];
}
2023-07-14 18:50:55 +08:00
- (void)configShareSDK {
2023-08-11 14:46:56 +08:00
2023-09-22 17:43:21 +08:00
[ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
///faceBook
2023-08-11 14:46:56 +08:00
// [platformsRegister setupFacebookWithAppkey:@"1266232494209868" appSecret:@"c9b170b383f8be9cdf118823b8632821" displayName:YMLocalizedString(@"AppDelegate_ThirdConfig0")];
2023-09-22 17:43:21 +08:00
[platformsRegister setupLineAuthType:SSDKAuthorizeTypeBoth];
}];
2023-07-06 16:54:13 +08:00
}
#pragma mark -
2023-07-14 18:50:55 +08:00
- (void)initEmojiData {
2023-07-06 16:54:13 +08:00
NSArray * dicArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"emoji" ofType:@"plist"]];
NSDictionary * dic = [dicArray firstObject];
NSArray * emojiArray = dic[@"data"];
NSMutableArray * array = [NSMutableArray array];
for (int i = 0; i < emojiArray.count; i++) {
NSDictionary * dic = [emojiArray objectAtIndex:i];
UIImage * image = [UIImage imageNamed:dic[@"file"]];
2023-07-14 18:50:55 +08:00
QEmotion * info = [[QEmotion alloc] init];
2023-07-06 16:54:13 +08:00
info.identifier = dic[@"id"];
info.image = image;
info.displayName = dic[@"tag"];
[array addObject:info];
}
2023-07-14 18:50:55 +08:00
//
QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper];
faceManager.emotionArray = array;
2023-07-06 16:54:13 +08:00
}
#pragma mark - 广
2023-07-14 18:50:55 +08:00
/**
广
*/
- (void)setupLaunchADView {
2023-07-06 16:54:13 +08:00
NSUserDefaults * kUserDefaults = NSUserDefaults.standardUserDefaults;
2023-07-14 18:50:55 +08:00
// 广
NSString *filePath = [XPAdImageTool.shareImageTool getFilePathWithImageName:[kUserDefaults valueForKey:adImageName]];
BOOL isExist = [XPAdImageTool.shareImageTool isFileExistWithFilePath:filePath];
2023-07-06 16:54:13 +08:00
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
if ([userDefault integerForKey:@"adShow"]) {
[userDefault setInteger:[userDefault integerForKey:@"adShow"]+1 forKey:@"adShow"];
} else {
[userDefault setInteger:1 forKey:@"adShow"];
}
2023-07-14 18:50:55 +08:00
if (isExist) {//
2023-07-06 16:54:13 +08:00
if ([userDefault integerForKey:@"adShow"] > 4) {
@kWeakify(self);
NSString *imageName = [kUserDefaults valueForKey:adImageName];
2023-07-14 18:50:55 +08:00
AdvertiseModel *info = [XPAdImageTool.shareImageTool getAdInfoFromCacheInMainWith:imageName];
XPAdvertiseView *advertiseView = [[XPAdvertiseView alloc] initWithFrame:self.window.bounds];
2023-07-06 16:54:13 +08:00
advertiseView.filePath = filePath;
2023-07-14 18:50:55 +08:00
advertiseView.dismissHandler = ^(BOOL shouldJump) {
2023-07-06 16:54:13 +08:00
@kStrongify(self)
if (!shouldJump || info == nil) {
return;
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self performSelectorOnMainThread:@selector(advertiseJumpHandleWithInfo:) withObject:info waitUntilDone:NO];
});
2023-07-06 16:54:13 +08:00
};
[advertiseView show];
}
}
}
2023-07-14 18:50:55 +08:00
/// 广
- (void)advertiseJumpHandleWithInfo:(AdvertiseModel *)info {
if (![ClientConfig shareConfig].canOpen) {
2023-07-06 16:54:13 +08:00
return;
}
if (UIApplication.sharedApplication.keyWindow != self.window) {
2023-07-14 18:50:55 +08:00
//
2023-07-06 16:54:13 +08:00
return;
}
switch (info.type) {
2023-07-14 18:50:55 +08:00
case SplashInfoSkipTypeRoom: {
if (![[XPAdImageTool shareImageTool] isImLogin]) {
return; //
2023-07-06 16:54:13 +08:00
}
2023-07-14 18:50:55 +08:00
//
2023-07-06 16:54:13 +08:00
if (info.link.length > 0) {
2023-07-14 18:50:55 +08:00
[XPRoomViewController openRoom:info.link viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
2023-07-06 16:54:13 +08:00
}
}
break;
2023-07-14 18:50:55 +08:00
case SplashInfoSkipTypeWeb: {
// H5
2023-07-06 16:54:13 +08:00
if (info.link.length > 0) {
2023-07-14 18:50:55 +08:00
XPWebViewController *webView = [[XPWebViewController alloc]init];
2023-07-06 16:54:13 +08:00
webView.url = info.link;
2023-07-14 18:50:55 +08:00
[[[XCCurrentVCStackManager shareManager]currentNavigationController] pushViewController:webView animated:YES];
2023-07-06 16:54:13 +08:00
}
}
break;
default:
break;
}
}
@end