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

232 lines
8.1 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>
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>
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
///
- (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];
[self initEmojiData];
2024-04-11 17:05:27 +08:00
}
2024-04-11 17:05:27 +08:00
-(void)setLanguage{
UISemanticContentAttribute attribute = UISemanticContentAttributeForceLeftToRight;
2024-04-11 17:05:27 +08:00
if (isMSRTL()) {
attribute = UISemanticContentAttributeForceRightToLeft;
2024-04-11 17:05:27 +08:00
}
[UIView appearance].semanticContentAttribute = attribute;
[UISearchBar appearance].semanticContentAttribute = attribute;
2024-02-21 10:18:59 +08:00
}
2024-02-21 10:18:59 +08:00
-(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];
});
2024-02-21 10:18:59 +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
*/
- (void) configBugly {
BuglyConfig *config = [[BuglyConfig alloc] init];
config.blockMonitorTimeout = 5;
2023-07-06 16:54:13 +08:00
2023-08-14 14:45:44 +08:00
#ifdef DEBUG
config.debugMode = NO;//YES; // debug
2024-06-28 11:35:19 +08:00
config.channel = [YYUtility getAppSource];
// config.blockMonitorEnable = YES; //
config.reportLogLevel = BuglyLogLevelSilent; // BuglyLogLevelVerbose; //
2024-06-28 11:35:19 +08:00
[Bugly startWithAppId:@"c937fd00f7" config:config];
2023-08-14 14:45:44 +08:00
#else
config.unexpectedTerminatingDetectionEnable = YES; // 退
2023-08-14 14:45:44 +08:00
config.debugMode = NO; // release
2024-06-28 11:35:19 +08:00
config.channel = [YYUtility getAppSource];;
config.blockMonitorEnable = NO; //
2023-08-14 14:45:44 +08:00
config.reportLogLevel = BuglyLogLevelWarn; //
NSString *buylyKey = @"8627948559"; // isEnterprise == NO ? @"5334684d86" : @"d65df59a68";
2023-10-09 10:27:53 +08:00
[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
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-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];
}];
2024-03-20 19:55:26 +08:00
NSString *isUpload = [[NSUserDefaults standardUserDefaults]valueForKey:@"kMobLinkUploadPrivacy"];
if (isUpload == nil){
[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 {
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++) {
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;
});
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 *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);
AdvertiseModel *info = [XPAdImageTool.shareImageTool getAdInfoFromCacheInMainWith:adName];
2023-07-14 18:50:55 +08:00
XPAdvertiseView *advertiseView = [[XPAdvertiseView alloc] initWithFrame:self.window.bounds];
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;
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[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;
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) {
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