72 lines
2.3 KiB
Objective-C
72 lines
2.3 KiB
Objective-C
//
|
||
// 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>
|
||
///Tool
|
||
#import "XPConstant.h"
|
||
#import "CustomAttachmentDecoder.h"
|
||
|
||
UIKIT_EXTERN NSString * kYinyouPrivateKey;
|
||
|
||
@implementation AppDelegate (ThirdConfig)
|
||
|
||
|
||
/// 初始化一些第三方配置
|
||
- (void)initThirdConfig {
|
||
[self configShareSDK];
|
||
[self configNIMSDK];
|
||
[self configUMengSDK];
|
||
}
|
||
|
||
- (void)configShareSDK {
|
||
[ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
|
||
//QQ
|
||
NSString *universalLink = @"https://6cqhk.share2dlink.com/";
|
||
NSString *qqUniversalLink = @"https://6cqhk.share2dlink.com/qq_conn/101937205";
|
||
[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];
|
||
}
|
||
|
||
#pragma mark - 友盟SDK
|
||
- (void)configUMengSDK {
|
||
// 只有同意过了隐私协议 才初始化
|
||
if ([[NSUserDefaults standardUserDefaults] objectForKey:kYinyouPrivateKey]) {
|
||
[UMConfigure initWithAppkey:KeyWithType(keyType_UMengAppKey) channel:KeyWithType(keyType_UMengAppChannel)];
|
||
}
|
||
}
|
||
|
||
@end
|