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>
|
2024-03-20 19:55:26 +08:00
|
|
|
|
#import <MOBFoundation/MobSDK+Privacy.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"
|
2024-02-21 10:18:59 +08:00
|
|
|
|
#import <UserNotifications/UserNotifications.h>
|
|
|
|
|
|
2023-08-14 14:45:44 +08:00
|
|
|
|
#import <Bugly/Bugly.h>
|
2025-08-28 14:40:05 +08:00
|
|
|
|
#import "BuglyManager.h"
|
2025-04-21 13:52:13 +08:00
|
|
|
|
#import <UIKit/UIDevice.h>
|
2023-08-11 14:46:56 +08:00
|
|
|
|
|
2023-12-29 16:43:37 +08:00
|
|
|
|
#import "YuMi-swift.h"
|
|
|
|
|
|
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
|
|
|
|
/// 初始化一些第三方配置
|
2024-06-12 11:23:10 +08:00
|
|
|
|
- (void)initThirdConfig{
|
2024-06-19 08:40:14 +08:00
|
|
|
|
[self setLanguage];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
[self configShareSDK];
|
|
|
|
|
[self configNIMSDK];
|
2023-08-14 14:45:44 +08:00
|
|
|
|
[self configBugly];
|
2024-02-21 10:18:59 +08:00
|
|
|
|
[self registerNot];
|
2024-06-12 11:23:10 +08:00
|
|
|
|
[self initEmojiData];
|
2024-04-11 17:05:27 +08:00
|
|
|
|
}
|
2024-06-12 11:23:10 +08:00
|
|
|
|
|
2024-04-11 17:05:27 +08:00
|
|
|
|
-(void)setLanguage{
|
2024-06-12 11:23:10 +08:00
|
|
|
|
UISemanticContentAttribute attribute = UISemanticContentAttributeForceLeftToRight;
|
2024-04-11 17:05:27 +08:00
|
|
|
|
if (isMSRTL()) {
|
2024-06-12 11:23:10 +08:00
|
|
|
|
attribute = UISemanticContentAttributeForceRightToLeft;
|
2024-04-11 17:05:27 +08:00
|
|
|
|
}
|
2024-06-12 11:23:10 +08:00
|
|
|
|
|
|
|
|
|
[UIView appearance].semanticContentAttribute = attribute;
|
|
|
|
|
[UISearchBar appearance].semanticContentAttribute = attribute;
|
2024-02-21 10:18:59 +08:00
|
|
|
|
}
|
2024-06-12 11:23:10 +08:00
|
|
|
|
|
2024-02-21 10:18:59 +08:00
|
|
|
|
-(void)registerNot{
|
|
|
|
|
if (@available(iOS 10.0, *)) {
|
2024-06-12 11:23:10 +08:00
|
|
|
|
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];
|
|
|
|
|
});
|
2024-02-21 10:18:59 +08:00
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
2024-06-12 11:23:10 +08:00
|
|
|
|
}];
|
|
|
|
|
}
|
2024-03-25 15:28:15 +08:00
|
|
|
|
}
|
2024-03-26 14:56:55 +08:00
|
|
|
|
|
2023-08-14 14:45:44 +08:00
|
|
|
|
/**
|
|
|
|
|
崩溃收集 Bugly
|
|
|
|
|
*/
|
2025-04-21 13:52:13 +08:00
|
|
|
|
|
2023-08-14 14:45:44 +08:00
|
|
|
|
- (void) configBugly {
|
2025-08-28 14:40:05 +08:00
|
|
|
|
// 使用 BuglyManager 统一管理 Bugly 配置
|
2023-08-14 14:45:44 +08:00
|
|
|
|
#ifdef DEBUG
|
2025-08-28 14:40:05 +08:00
|
|
|
|
[[BuglyManager sharedManager] configureWithAppId:@"c937fd00f7" debug:YES];
|
2023-08-14 14:45:44 +08:00
|
|
|
|
#else
|
2025-08-28 14:40:05 +08:00
|
|
|
|
[[BuglyManager sharedManager] configureWithAppId:@"8627948559" debug:NO];
|
2023-08-14 14:45:44 +08:00
|
|
|
|
#endif
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
- (void)configNIMSDK {
|
|
|
|
|
//推荐在程序启动的时候初始化 NIMSDK
|
2025-08-14 18:48:47 +08:00
|
|
|
|
NSString *appKey = [[ClientConfig shareConfig].configInfo nimKey];
|
|
|
|
|
if ([NSString isEmpty:appKey]) {
|
|
|
|
|
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]];
|
2025-08-19 16:33:22 +08:00
|
|
|
|
[[NIMSDKConfig sharedConfig] setShouldSyncStickTopSessionInfos:YES];
|
2023-07-06 16:54:13 +08:00
|
|
|
|
[NIMSDKConfig sharedConfig].shouldConsiderRevokedMessageUnreadCount = YES;
|
2025-08-19 16:33:22 +08:00
|
|
|
|
|
|
|
|
|
// cdn统计回调不触发
|
|
|
|
|
[NIMSDKConfig sharedConfig].cdnTrackInterval = 0;
|
|
|
|
|
|
|
|
|
|
// 最小时间间隔设置为最小边界值
|
|
|
|
|
[NIMSDKConfig sharedConfig].chatroomMessageReceiveMinInterval = 50;
|
|
|
|
|
|
2023-07-06 16:54:13 +08:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
[NIMSDKConfig sharedConfig].enabledHttpsForInfo = NO;
|
|
|
|
|
[NIMSDKConfig sharedConfig].enabledHttpsForMessage = NO;
|
2025-08-19 16:33:22 +08:00
|
|
|
|
#else
|
|
|
|
|
// 生产环境启用HTTPS
|
|
|
|
|
[NIMSDKConfig sharedConfig].enabledHttpsForInfo = YES;
|
|
|
|
|
[NIMSDKConfig sharedConfig].enabledHttpsForMessage = YES;
|
2023-07-06 16:54:13 +08:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
- (void)configShareSDK {
|
2023-12-29 16:43:37 +08:00
|
|
|
|
|
2025-04-21 13:52:13 +08:00
|
|
|
|
// [PILineLoginManager registerLine];
|
2023-12-29 16:43:37 +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];
|
|
|
|
|
}];
|
2024-06-12 11:23:10 +08:00
|
|
|
|
|
2024-03-20 19:55:26 +08:00
|
|
|
|
NSString *isUpload = [[NSUserDefaults standardUserDefaults]valueForKey:@"kMobLinkUploadPrivacy"];
|
|
|
|
|
if (isUpload == nil){
|
2024-06-12 11:23:10 +08:00
|
|
|
|
[MobSDK uploadPrivacyPermissionStatus:YES onResult:nil];
|
2024-03-20 19:55:26 +08:00
|
|
|
|
[[NSUserDefaults standardUserDefaults] setValue:@"YES" forKey:@"kMobLinkUploadPrivacy"];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
|
}
|
2023-07-06 16:54:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - 表情
|
2023-07-14 18:50:55 +08:00
|
|
|
|
- (void)initEmojiData {
|
2024-06-12 11:23:10 +08:00
|
|
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
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++) {
|
2025-06-16 17:30:20 +08:00
|
|
|
|
|
2025-08-26 13:57:24 +08:00
|
|
|
|
NSDictionary * emotionDic = [emojiArray xpSafeObjectAtIndex:i];
|
|
|
|
|
if (!emotionDic) continue;
|
2025-06-16 17:30:20 +08:00
|
|
|
|
|
2025-08-26 13:57:24 +08:00
|
|
|
|
UIImage * image = [UIImage imageNamed:emotionDic[@"file"]];
|
|
|
|
|
QEmotion * info = [[QEmotion alloc] init];
|
2025-06-16 17:30:20 +08:00
|
|
|
|
|
2025-08-26 13:57:24 +08:00
|
|
|
|
info.displayName = emotionDic[@"tag"];
|
|
|
|
|
info.identifier = emotionDic[@"id"];
|
2024-06-12 11:23:10 +08:00
|
|
|
|
info.image = image;
|
2025-06-16 17:30:20 +08:00
|
|
|
|
|
2024-06-12 11:23:10 +08:00
|
|
|
|
[array addObject:info];
|
|
|
|
|
}
|
|
|
|
|
//在这里强烈建议先预加载一下表情
|
|
|
|
|
QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper];
|
|
|
|
|
faceManager.emotionArray = array;
|
2025-08-26 13:57:24 +08:00
|
|
|
|
|
2025-08-27 16:35:52 +08:00
|
|
|
|
// 清理 emoji 缓存,确保新的尺寸设置生效
|
|
|
|
|
[QEmotionHelper clearEmojiCache];
|
2024-06-12 11:23:10 +08:00
|
|
|
|
});
|
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
|
|
|
|
// 判断沙盒中是否存在广告图片,如果存在,直接显示
|
2024-06-12 11:23:10 +08:00
|
|
|
|
NSString *adName = [kUserDefaults stringForKey:adImageName];
|
|
|
|
|
NSString *filePath = [XPAdImageTool.shareImageTool getFilePathWithImageName:adName];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
BOOL isExist = [XPAdImageTool.shareImageTool isFileExistWithFilePath:filePath];
|
2023-07-06 16:54:13 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
if (isExist) {// 图片存在
|
2025-01-07 20:07:54 +08:00
|
|
|
|
// if ([kUserDefaults integerForKey:@"adShow"] > 4) {
|
2023-07-06 16:54:13 +08:00
|
|
|
|
@kWeakify(self);
|
2024-06-12 11:23:10 +08:00
|
|
|
|
AdvertiseModel *info = [XPAdImageTool.shareImageTool getAdInfoFromCacheInMainWith:adName];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
XPAdvertiseView *advertiseView = [[XPAdvertiseView alloc] initWithFrame:self.window.bounds];
|
2024-12-31 15:09:44 +08:00
|
|
|
|
advertiseView.type = info.type;
|
|
|
|
|
advertiseView.fileModel = info.fillVo;
|
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(), ^{
|
2024-06-12 11:23:10 +08:00
|
|
|
|
[self advertiseJumpHandleWithInfo:info];
|
|
|
|
|
});
|
2023-07-06 16:54:13 +08:00
|
|
|
|
};
|
|
|
|
|
[advertiseView show];
|
2025-01-07 20:07:54 +08:00
|
|
|
|
// }
|
2023-07-06 16:54:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
/// 闪屏广告跳转处理
|
|
|
|
|
- (void)advertiseJumpHandleWithInfo:(AdvertiseModel *)info {
|
2023-07-06 16:54:13 +08:00
|
|
|
|
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;
|
2024-12-31 15:09:44 +08:00
|
|
|
|
case SplashInfoSkipTypeWeb:
|
|
|
|
|
case SplashInfoSkipTypeWeb_CP:
|
|
|
|
|
case SplashInfoSkipTypeWeb_Custom:
|
|
|
|
|
case SplashInfoSkipTypeWeb_WeekStar: {
|
2023-07-14 18:50:55 +08:00
|
|
|
|
// 跳转 H5
|
2023-07-06 16:54:13 +08:00
|
|
|
|
if (info.link.length > 0) {
|
2024-10-08 11:47:06 +08:00
|
|
|
|
XPWebViewController *webView = [[XPWebViewController alloc] initWithRoomUID:nil];
|
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
|