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>
|
2024-02-21 10:18:59 +08:00
|
|
|
|
#import <UserNotifications/UserNotifications.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>
|
2024-02-21 10:18:59 +08:00
|
|
|
|
#import <UserNotifications/UserNotifications.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-12-29 16:43:37 +08:00
|
|
|
|
#import "YuMi-swift.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;
|
|
|
|
|
|
2023-12-29 16:43:37 +08:00
|
|
|
|
|
|
|
|
|
|
2023-07-06 16:54:13 +08:00
|
|
|
|
@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];
|
2024-02-21 10:18:59 +08:00
|
|
|
|
[self registerNot];
|
|
|
|
|
}
|
|
|
|
|
-(void)registerNot{
|
|
|
|
|
if (@available(iOS 10.0, *)) {
|
|
|
|
|
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
|
|
|
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound) completionHandler:^(BOOL granted, NSError * _Nullable error) {
|
|
|
|
|
if (granted) {
|
|
|
|
|
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
|
|
|
|
|
if (settings.authorizationStatus == UNAuthorizationStatusAuthorized){
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-06 16:54:13 +08:00
|
|
|
|
}
|
2023-08-14 14:45:44 +08:00
|
|
|
|
/**
|
|
|
|
|
崩溃收集 Bugly
|
|
|
|
|
*/
|
|
|
|
|
- (void) configBugly {
|
|
|
|
|
|
|
|
|
|
BuglyConfig *config = [[BuglyConfig alloc] init];
|
2023-10-09 10:27:53 +08:00
|
|
|
|
|
2023-08-14 14:45:44 +08:00
|
|
|
|
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 模式下,开启调试模式
|
2023-10-09 10:27:53 +08:00
|
|
|
|
config.channel = [YYUtility getAppSource];; config.blockMonitorEnable = YES; // 卡顿监控开关,默认关闭
|
2023-08-14 14:45:44 +08:00
|
|
|
|
config.reportLogLevel = BuglyLogLevelVerbose; // 设置打印日志级别
|
|
|
|
|
[Bugly startWithAppId:@"86cf73b8d5" config:config];
|
|
|
|
|
#else
|
|
|
|
|
config.debugMode = NO; // release 模式下,关闭调试模式
|
2023-10-09 10:27:53 +08:00
|
|
|
|
config.channel = [YYUtility getAppSource];; config.blockMonitorEnable = NO; // 卡顿监控开关,默认关闭
|
2023-08-14 14:45:44 +08:00
|
|
|
|
config.reportLogLevel = BuglyLogLevelWarn; // 设置自定义日志上报的级别,默认不上报自定义日志
|
2023-10-09 10:27:53 +08:00
|
|
|
|
NSString *buylyKey = isEnterprise == NO ? @"5334684d86" : @"d65df59a68";
|
|
|
|
|
[Bugly startWithAppId:buylyKey config:config];
|
2023-08-14 14:45:44 +08:00
|
|
|
|
#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];
|
2024-02-21 10:18:59 +08:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
option.apnsCername = @"pikoDevelopPush";
|
|
|
|
|
#else
|
2023-10-10 14:17:04 +08:00
|
|
|
|
option.apnsCername = @"newPiko";
|
2024-02-21 10:18:59 +08:00
|
|
|
|
#endif
|
2024-02-26 17:18:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-06 16:54:13 +08:00
|
|
|
|
[[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-12-29 16:43:37 +08:00
|
|
|
|
|
|
|
|
|
[PILineLoginManager registerLine];
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2023-08-16 17:03:40 +08:00
|
|
|
|
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
|