Files
yinmeng-ios/xplan-ios/Appdelegate/AppDelegate+ThirdConfig.m
2022-10-31 10:56:21 +08:00

120 lines
4.0 KiB
Objective-C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// AppDelegate+ThirdConfig.m
// xplan-ios
//
// Created by 冯硕 on 2021/9/13.
//
#import "AppDelegate+ThirdConfig.h"
///Third
#import <ShareSDK/ShareSDK.h>
#import <NIMSDK/NIMSDK.h>
#import <UMCommon/UMCommon.h>
#import <UserNotifications/UNUserNotificationCenter.h>
#import <Bugly/Bugly.h>
///Tool
#import "XPConstant.h"
#import "CustomAttachmentDecoder.h"
#import "QEmotionHelper.h"
UIKIT_EXTERN NSString * kYinyouPrivateKey;
@implementation AppDelegate (ThirdConfig)
/// 初始化一些第三方配置
- (void)initThirdConfig {
[self configShareSDK];
[self configNIMSDK];
[self configUMengSDK];
[self initEmojiData];
[self configBugly];
}
- (void)configShareSDK {
[ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
//QQ
NSString *universalLink = @"https://a6lno.share2dlink.com/";
NSString *qqUniversalLink = @"https://a6lno.share2dlink.com/qq_conn/101902443";
[platformsRegister setupQQWithAppId:KeyWithType(KeyType_QQAppid) appkey:KeyWithType(KeyType_QQSecret) enableUniversalLink:YES universalLink:qqUniversalLink];
[platformsRegister setupWeChatWithAppId:KeyWithType(KeyType_WechatAppid) appSecret:KeyWithType(KeyType_WechatSecret) universalLink:universalLink];
}];
}
- (void)configNIMSDK {
//推荐在程序启动的时候初始化 NIMSDK
NSString *appKey = KeyWithType(KeyType_NetEase);
NIMSDKOption *option = [NIMSDKOption optionWithAppKey:appKey];
option.apnsCername = KeyWithType(KeyType_APNSCer);
[[NIMSDK sharedSDK] registerWithOption:option];
// NIM SDK初始化
[NIMCustomObject registerCustomDecoder:[[CustomAttachmentDecoder alloc] init]];
#ifdef DEBUG
[NIMSDKConfig sharedConfig].enabledHttpsForInfo = NO;
[NIMSDKConfig sharedConfig].enabledHttpsForMessage = NO;
#endif
if (@available(iOS 11.0, *)){
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) {
}];
}
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
/**
崩溃收集 Bugly
*/
- (void) configBugly {
BuglyConfig *config = [[BuglyConfig alloc] init];
config.channel = @"App Enterprise";
config.blockMonitorEnable = YES; // 卡顿监控开关,默认关闭
config.blockMonitorTimeout = 5;
config.unexpectedTerminatingDetectionEnable = YES; // 非正常退出事件记录开关,默认关闭
#ifdef DEBUG
config.debugMode = YES; // debug 模式下,开启调试模式
config.reportLogLevel = BuglyLogLevelVerbose; // 设置打印日志级别
[Bugly startWithAppId:@"bb158b9965" config:config];
#else
config.debugMode = NO; // release 模式下,关闭调试模式
config.reportLogLevel = BuglyLogLevelWarn; // 设置自定义日志上报的级别,默认不上报自定义日志
[Bugly startWithAppId:@"bb158b9965" config:config];
#endif
}
#pragma mark - 友盟SDK
- (void)configUMengSDK {
// 只有同意过了隐私协议 才初始化
if ([[NSUserDefaults standardUserDefaults] objectForKey:kYinyouPrivateKey]) {
[UMConfigure initWithAppkey:KeyWithType(keyType_UMengAppKey) channel:KeyWithType(keyType_UMengAppChannel)];
}
}
#pragma mark - 表情
- (void)initEmojiData {
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"]];
QEmotion * info = [[QEmotion alloc] init];
info.identifier = dic[@"id"];
info.image = image;
info.displayName = dic[@"tag"];
[array addObject:info];
}
//在这里强烈建议先预加载一下表情
QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper];
faceManager.emotionArray = array;
}
@end