|
@@ -6,13 +6,13 @@
|
|
|
//
|
|
|
|
|
|
#import "AppDelegate.h"
|
|
|
+#import "KSTabBarViewController.h"
|
|
|
+#import "InstitutionTabBarController.h"
|
|
|
#import <AppTrackingTransparency/AppTrackingTransparency.h>
|
|
|
#import "KSUpdateManager.h"
|
|
|
#import "KSUpdateAlert.h"
|
|
|
#import "KSNetworkAccessibleManager.h"
|
|
|
#import <Bugly/Bugly.h>
|
|
|
-#import <RongIMLib/RongIMLib.h>
|
|
|
-#import <RongIMKit/RongIMKit.h>
|
|
|
|
|
|
#import <UMCommon/UMCommon.h>
|
|
|
|
|
@@ -28,9 +28,7 @@
|
|
|
#import "UrlDecode.h"
|
|
|
#import "KSBaseWKWebViewController.h"
|
|
|
#import "UserInfoManager.h"
|
|
|
-#import "KSIMService.h"
|
|
|
-#import "RCConnectionManager.h"
|
|
|
-#import "KSRCIMDataSource.h"
|
|
|
+
|
|
|
#import "WXApi.h"
|
|
|
#import "GuideViewController.h"
|
|
|
#import "HomeworkDetailViewController.h"
|
|
@@ -39,21 +37,13 @@
|
|
|
#import "LaunchAnimationViewController.h"
|
|
|
#import "KSEnterLiveroomManager.h"
|
|
|
|
|
|
-@interface RCNaviDataInfo : NSObject
|
|
|
-
|
|
|
-@property (nonatomic, assign) NSTimeInterval uploadVideoDurationLimit;
|
|
|
-
|
|
|
-@end
|
|
|
-
|
|
|
-@interface RCNaviDataManager : NSObject
|
|
|
-
|
|
|
-@property (nonatomic, strong) RCNaviDataInfo *naviData;
|
|
|
-
|
|
|
-+ (instancetype)sharedInstance;
|
|
|
+#import "TXIMLinsenter.h"
|
|
|
+#import <TUICore/TUIConfig.h>
|
|
|
+#import <TUIChat/TUIChat.h>
|
|
|
|
|
|
-@end
|
|
|
+@import TXLiteAVSDK_Professional;
|
|
|
|
|
|
-@interface AppDelegate ()<RCIMReceiveMessageDelegate,WXApiDelegate,JPUSHRegisterDelegate>
|
|
|
+@interface AppDelegate ()<WXApiDelegate,JPUSHRegisterDelegate,V2TXLivePremierObserver>
|
|
|
|
|
|
@property (nonatomic, assign) BOOL isNeedUpdate;
|
|
|
|
|
@@ -92,6 +82,7 @@
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
|
// Override point for customization after application launch.
|
|
|
[self networkEnableCheck];
|
|
|
+ [self initTXRTCConfig];
|
|
|
[self registerSDK];
|
|
|
[Bugly startWithAppId:@"adfcb3bc3d"];
|
|
|
|
|
@@ -102,15 +93,17 @@
|
|
|
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
|
|
|
}
|
|
|
|
|
|
- [[UITabBar appearance] setTranslucent:NO];
|
|
|
// 全局配置光标颜色
|
|
|
- [[UITextField appearance] setTintColor:THEMECOLOR];
|
|
|
- [[UITextView appearance] setTintColor:THEMECOLOR];
|
|
|
+ [[UITextField appearance] setTintColor:CLIENT_THEMECOLOR];
|
|
|
+ [[UITextView appearance] setTintColor:CLIENT_THEMECOLOR];
|
|
|
|
|
|
// 配置极光推送
|
|
|
[self configJPUSHWithLaunchOptions:launchOptions];
|
|
|
- // 融云相关配置
|
|
|
- [self configIM];
|
|
|
+
|
|
|
+
|
|
|
+ // 腾讯群相关
|
|
|
+ [self configTXIM];
|
|
|
+
|
|
|
LaunchAnimationViewController *animationVC = [[LaunchAnimationViewController alloc] init];
|
|
|
MJWeakSelf;
|
|
|
[animationVC launchAnimationFinish:^{
|
|
@@ -144,13 +137,21 @@
|
|
|
*/
|
|
|
[self registerRemoteNotification:application];
|
|
|
|
|
|
- if(@available(iOS 11.0, *)){
|
|
|
-
|
|
|
- [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UIDocumentBrowserViewController class]]].tintColor = THEMECOLOR;
|
|
|
- }
|
|
|
+ [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UIDocumentBrowserViewController class]]].tintColor = CLIENT_THEMECOLOR;
|
|
|
return YES;
|
|
|
}
|
|
|
|
|
|
+- (void)refreshThemeColorAndConfig {
|
|
|
+ // 全局配置光标颜色
|
|
|
+ NSLog(@"------ %zd",[UserDefaultObjectForKey(TENANT_ID) integerValue]);
|
|
|
+ [[UITextField appearance] setTintColor:CLIENT_THEMECOLOR];
|
|
|
+ [[UITextView appearance] setTintColor:CLIENT_THEMECOLOR];
|
|
|
+
|
|
|
+ [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UIDocumentBrowserViewController class]]].tintColor = CLIENT_THEMECOLOR;
|
|
|
+ TUIConfig *config = [TUIConfig defaultConfig];
|
|
|
+ config.defaultGroupAvatarImage = [UIImage imageNamed:CLIENT_GROUP_LOGO];
|
|
|
+}
|
|
|
+
|
|
|
- (void)configRootVC {
|
|
|
BOOL hasLaunchGuide = UserDefaultBoolForKey(FIRST_LOGIN_KEY);
|
|
|
if (hasLaunchGuide == NO) {
|
|
@@ -167,22 +168,19 @@
|
|
|
}
|
|
|
else {
|
|
|
[KSNetworkingManager configRequestHeader];
|
|
|
+ NSInteger tenantId = [UserDefaultObjectForKey(TENANT_ID) integerValue];
|
|
|
+ if (tenantId != -1) {
|
|
|
+ [KSNetworkingManager addHeader:[NSString stringWithFormat:@"%zd", tenantId] forKey:@"coopId"];
|
|
|
+ }
|
|
|
[USER_MANAGER queryUserInfoSendLoginUMCount];
|
|
|
[self initTableBar];
|
|
|
- self.window.rootViewController=_tabBarController;
|
|
|
}
|
|
|
}
|
|
|
[self versionCheck];
|
|
|
}
|
|
|
|
|
|
- (void)displayUnreadMessageCount {
|
|
|
- int unreadMsgCount = [[RCIMClient sharedRCIMClient] getUnreadCount:@[ @(ConversationType_PRIVATE),@(ConversationType_APPSERVICE), @(ConversationType_GROUP),@(ConversationType_SYSTEM)
|
|
|
- ]];
|
|
|
- if (unreadMsgCount >= 1) {
|
|
|
- [self.tabBarController noteNewsWithIndex:2 count:unreadMsgCount];
|
|
|
- } else {
|
|
|
- [self.tabBarController clearNewsWithIndex:2];
|
|
|
- }
|
|
|
+ [self countUnreadMessage];
|
|
|
}
|
|
|
|
|
|
- (void)registerSDK {
|
|
@@ -285,69 +283,29 @@
|
|
|
advertisingIdentifier:nil];
|
|
|
}
|
|
|
|
|
|
-- (void)configIM {
|
|
|
- [RCNaviDataManager sharedInstance].naviData.uploadVideoDurationLimit = 480.0f;
|
|
|
- // 6tnym1br6pv07 正式环境key c9kqb3rdc451j test
|
|
|
- [[RCIM sharedRCIM] initWithAppKey:RCIM_KEY];
|
|
|
-
|
|
|
- //IMKit连接状态的监听器
|
|
|
- [[RCIM sharedRCIM] setConnectionStatusDelegate:KSRMLINK];
|
|
|
- //IMKit消息接收的监听器
|
|
|
- [[RCIM sharedRCIM] setReceiveMessageDelegate:self];
|
|
|
- // 信息提供者
|
|
|
- [RCIM sharedRCIM].userInfoDataSource = KSRMDataSource;
|
|
|
- [[RCIM sharedRCIM] setGroupInfoDataSource:KSRMDataSource];
|
|
|
- // 群名片信息提供者
|
|
|
- [[RCIM sharedRCIM] setGroupUserInfoDataSource:KSRMDataSource];
|
|
|
- // 群成员数据源
|
|
|
- [RCIM sharedRCIM].groupMemberDataSource = KSRMDataSource;
|
|
|
-
|
|
|
- //开启消息@功能(只支持群聊和讨论组, App需要实现群成员数据源groupMemberDataSource)
|
|
|
- RCKitConfigCenter.message.enableMessageMentioned = YES;
|
|
|
- //是否关闭本地通知,默认是打开的
|
|
|
- RCKitConfigCenter.message.disableMessageNotificaiton = NO;
|
|
|
- // 会话界面设置
|
|
|
- RCKitConfigCenter.ui.globalMessageAvatarStyle = RC_USER_AVATAR_RECTANGLE;
|
|
|
- RCKitConfigCenter.ui.globalMessagePortraitSize = CGSizeMake(40, 40);
|
|
|
- // 会话列表头像设置
|
|
|
- RCKitConfigCenter.ui.globalConversationAvatarStyle = RC_USER_AVATAR_RECTANGLE;
|
|
|
- RCKitConfigCenter.ui.globalConversationPortraitSize = CGSizeMake(44, 44);
|
|
|
-
|
|
|
- //开启消息撤回功能
|
|
|
- RCKitConfigCenter.message.enableMessageRecall = YES;
|
|
|
- // 开启消息合并转发
|
|
|
- RCKitConfigCenter.message.enableSendCombineMessage = YES;
|
|
|
- //选择媒体资源时,包含视频文件
|
|
|
- RCKitConfigCenter.message.isMediaSelectorContainVideo = YES;
|
|
|
- //设置显示未注册的消息
|
|
|
- RCKitConfigCenter.message.showUnkownMessage = YES;
|
|
|
-
|
|
|
- //开启发送已读回执
|
|
|
- RCKitConfigCenter.message.enabledReadReceiptConversationTypeList = @[@(ConversationType_PRIVATE), @(ConversationType_GROUP)];
|
|
|
-
|
|
|
- //开启输入状态监听
|
|
|
- RCKitConfigCenter.message.enableTypingStatus = YES;
|
|
|
-
|
|
|
- //开启用户信息和群组信息的持久化
|
|
|
- [RCIM sharedRCIM].enablePersistentUserInfoCache = YES;
|
|
|
- // 在发送的所有消息中携带当前登录的用户信息
|
|
|
- [RCIM sharedRCIM].enableMessageAttachUserInfo = YES;
|
|
|
- // 关闭所有提示音
|
|
|
- RCKitConfigCenter.message.disableMessageAlertSound = YES;
|
|
|
-
|
|
|
- // 设置断线重连时是否踢出重连设备
|
|
|
- [[RCIMClient sharedRCIMClient] setReconnectKickEnable:YES];
|
|
|
-
|
|
|
- // 左右上角按钮颜色
|
|
|
- RCKitConfigCenter.ui.globalNavigationBarTintColor = HexRGB(0x000000);
|
|
|
- // 注册消息
|
|
|
- // 注册消息
|
|
|
- [[RCIM sharedRCIM] registerMessageType:NSClassFromString(@"KSChatLiveMessage")];
|
|
|
- [[RCIM sharedRCIM] registerMessageType:NSClassFromString(@"KSChatMusicMessage")];
|
|
|
-
|
|
|
- // [[RCIMClient sharedRCIMClient] setLogLevel:RC_Log_Level_Verbose];
|
|
|
- // [self redirectNSlogToDocumentFolder];
|
|
|
+- (void)initTXRTCConfig {
|
|
|
+ [V2TXLivePremier setLicence:CONFIG_TXLiveLicenceURL key:CONFIG_TXLiveLicenceKey];
|
|
|
+ [V2TXLivePremier setObserver:self];
|
|
|
+ NSLog(@"SDK Version = %@", [V2TXLivePremier getSDKVersionStr]);
|
|
|
+}
|
|
|
+
|
|
|
+- (void)configTXIM {
|
|
|
+ TUIConfig *config = [TUIConfig defaultConfig];
|
|
|
+ // 修改默认头像
|
|
|
+ config.defaultAvatarImage = [UIImage imageNamed:USERDEFAULT_LOGO];
|
|
|
+ // 修改默认群组头像
|
|
|
+ config.defaultGroupAvatarImage = [UIImage imageNamed:CLIENT_GROUP_LOGO];
|
|
|
+ // 禁用群组九宫格头像
|
|
|
+ config.avatarType = TAvatarTypeRadiusCorner;
|
|
|
+ config.enableGroupGridAvatar = NO;
|
|
|
+ config.avatarCornerRadius = 4.0f;
|
|
|
+ // 关闭toaset
|
|
|
+ config.enableToast = NO;
|
|
|
|
|
|
+ TUIChatConfig *chatConfig = [TUIChatConfig defaultConfig];
|
|
|
+ chatConfig.backgroudColor = HexRGB(0xF8F8F8);
|
|
|
+ chatConfig.enableWelcomeCustomMessage = NO;
|
|
|
+ chatConfig.enableTypingStatus = YES;
|
|
|
}
|
|
|
|
|
|
#pragma mark - private method
|
|
@@ -400,32 +358,34 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
/// Required - 注册 DeviceToken
|
|
|
[JPUSHService registerDeviceToken:deviceToken];
|
|
|
|
|
|
- // 融云
|
|
|
- [[RCIMClient sharedRCIMClient] setDeviceTokenData:deviceToken];
|
|
|
+
|
|
|
+ if ([TXIM_LINSENTER isCurrentUserLoginIM]) {
|
|
|
+ [self registerTXIMDeviceToken:deviceToken];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.deviceToken = deviceToken;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
|
|
- /**
|
|
|
- * 获取融云推送服务扩展字段2
|
|
|
- */
|
|
|
- NSDictionary *pushServiceData = [[RCIMClient sharedRCIMClient] getPushExtraFromRemoteNotification:userInfo];
|
|
|
- if (pushServiceData) {
|
|
|
- NSLog(@"该远程推送包含来自融云的推送服务");
|
|
|
- /**
|
|
|
- * 统计推送打开率2
|
|
|
- */
|
|
|
- [[RCIMClient sharedRCIMClient] recordRemoteNotificationEvent:userInfo];
|
|
|
-
|
|
|
- for (id key in [pushServiceData allKeys]) {
|
|
|
- NSLog(@"key = %@, value = %@", key, pushServiceData[key]);
|
|
|
- }
|
|
|
- } else {
|
|
|
- NSLog(@"该远程推送不包含来自融云的推送服务");
|
|
|
- // 极光推送
|
|
|
- [JPUSHService handleRemoteNotification:userInfo];
|
|
|
+- (void)registerTXIMDeviceToken:(NSData *)deviceToken {
|
|
|
+ if (deviceToken) {
|
|
|
+ V2TIMAPNSConfig *config = [[V2TIMAPNSConfig alloc] init];
|
|
|
+ config.businessID = TXOfflinePushCertificateIDForAPNS;
|
|
|
+ config.token = deviceToken;
|
|
|
+ [[V2TIMManager sharedInstance] setAPNS:config succ:^{
|
|
|
+ NSLog(@"%s, succ", __func__);
|
|
|
+ } fail:^(int code, NSString *desc) {
|
|
|
+ NSLog(@"%s, fail, %d, %@", __func__, code, desc);
|
|
|
+ }];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
|
|
+
|
|
|
+ // 极光推送
|
|
|
+ [JPUSHService handleRemoteNotification:userInfo];
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* 推送处理4
|
|
|
* userInfo内容请参考官网文档
|
|
@@ -433,25 +393,10 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
#pragma clang diagnostic push
|
|
|
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
|
|
|
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
|
|
|
- /**
|
|
|
- * 统计推送打开率2
|
|
|
- */
|
|
|
- [[RCIMClient sharedRCIMClient] recordRemoteNotificationEvent:userInfo];
|
|
|
- /**
|
|
|
- * 获取融云推送服务扩展字段2
|
|
|
- */
|
|
|
- NSDictionary *pushServiceData = [[RCIMClient sharedRCIMClient] getPushExtraFromRemoteNotification:userInfo];
|
|
|
- if (pushServiceData) {
|
|
|
- NSLog(@"该远程推送包含来自融云的推送服务");
|
|
|
- for (id key in [pushServiceData allKeys]) {
|
|
|
- NSLog(@"key = %@, value = %@", key, pushServiceData[key]);
|
|
|
- }
|
|
|
- } else {
|
|
|
- NSLog(@"该远程推送不包含来自融云的推送服务");
|
|
|
+
|
|
|
// 极光推送
|
|
|
[JPUSHService handleRemoteNotification:userInfo];
|
|
|
}
|
|
|
-}
|
|
|
#pragma clang diagnostic pop
|
|
|
|
|
|
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
|
@@ -477,13 +422,7 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
if (self.isNeedUpdate) {
|
|
|
[self versionCheck];
|
|
|
}
|
|
|
- RCConnectionStatus status = [[RCIMClient sharedRCIMClient] getConnectionStatus];
|
|
|
- if (status == ConnectionStatus_Unconnected) { // 连接失败或未连接 需要重新连接
|
|
|
- NSString *token = UserDefault(TokenKey);
|
|
|
- if (![NSString isEmptyString:token]) {
|
|
|
- [USER_MANAGER checkTokenEnableConnectRongCloud];
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
// 退到后台发送消息
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"appEnterForeground" object:nil];
|
|
|
}
|
|
@@ -499,43 +438,6 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
|
|
}
|
|
|
|
|
|
-- (void)onRCIMReceiveMessage:(RCMessage *)message left:(int)left {
|
|
|
-
|
|
|
- NSLog(@"conversationType----%lu",(unsigned long)message.conversationType);
|
|
|
- // 此处根据消息类型处理对应信息
|
|
|
- if (message.conversationType == ConversationType_CHATROOM) { // 聊天室类型为直播
|
|
|
- [[KSIMService sharedService] ksOnReceivedChatroom:message left:left object:@""];
|
|
|
- }
|
|
|
- if (message.conversationType == ConversationType_GROUP && ![message.targetId containsString:@"COURSE"] && ![message.targetId containsString:@"FAN"]) { // 网络教室视频聊天
|
|
|
- [[RCIMClient sharedRCIMClient] clearMessagesUnreadStatus:ConversationType_GROUP targetId:message.targetId];
|
|
|
- [[KSIMService sharedService] ksOnReceived:message left:left object:@""];
|
|
|
- }
|
|
|
- else {
|
|
|
- // 此处对单聊、群聊消息处理
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
-
|
|
|
- if ([message.content isMemberOfClass:[RCGroupNotificationMessage class]]) {
|
|
|
- RCGroupNotificationMessage *msg = (RCGroupNotificationMessage *)message.content;
|
|
|
- if ([msg.operation isEqualToString:GroupNotificationMessage_GroupOperationKicked]) {
|
|
|
- // [[RCIMClient sharedRCIMClient] removeConversation:ConversationType_GROUP targetId:message.targetId];
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- int unreadMsgCount = [[RCIMClient sharedRCIMClient] getUnreadCount:@[
|
|
|
- @(ConversationType_PRIVATE), @(ConversationType_APPSERVICE), @(ConversationType_GROUP),@(ConversationType_SYSTEM)
|
|
|
- ]];
|
|
|
- [UIApplication sharedApplication].applicationIconBadgeNumber = unreadMsgCount;
|
|
|
- if (unreadMsgCount >= 1) {
|
|
|
- [self.tabBarController noteNewsWithIndex:2 count:unreadMsgCount];
|
|
|
- } else {
|
|
|
- [self.tabBarController clearNewsWithIndex:2];
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
#pragma mark- JPUSHRegisterDelegate
|
|
|
- (void)jpushNotificationAuthorization:(JPAuthorizationStatus)status withInfo:(NSDictionary *)info {
|
|
@@ -771,9 +673,9 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
|
|
|
NSString *newToken = [dic ks_stringValueForKey:@"data"];
|
|
|
if (![NSString isEmptyString:newToken]) {
|
|
|
- UserDefaultSet(newToken, RongTokenKey);
|
|
|
+ UserDefaultSet(newToken, IM_TOKEN);
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
- [USER_MANAGER checkTokenEnableConnectRongCloud];
|
|
|
+ [USER_MANAGER checkTokenEnableConnectIM];
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -788,19 +690,18 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
if (self.tabBarController) {
|
|
|
[self.tabBarController removeControllerNotifer];
|
|
|
}
|
|
|
-
|
|
|
- self.tabBarController = [[KSTabBarViewController alloc] init];
|
|
|
- self.window.rootViewController = self.tabBarController;
|
|
|
- int unreadMsgCount = [[RCIMClient sharedRCIMClient] getUnreadCount:@[ @(ConversationType_PRIVATE),@(ConversationType_APPSERVICE), @(ConversationType_GROUP),@(ConversationType_SYSTEM)
|
|
|
- ]];
|
|
|
- if (unreadMsgCount >= 1) {
|
|
|
- [self.tabBarController noteNewsWithIndex:2 count:unreadMsgCount];
|
|
|
- } else {
|
|
|
- [self.tabBarController clearNewsWithIndex:2];
|
|
|
+ // -1 为平台用户
|
|
|
+ if ([UserDefaultObjectForKey(TENANT_ID) integerValue] <= 0) {
|
|
|
+ self.tabBarController = [[KSTabBarViewController alloc] init];
|
|
|
+ self.window.rootViewController = self.tabBarController;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.tabBarController = [[InstitutionTabBarController alloc] init];
|
|
|
+ self.window.rootViewController = self.tabBarController;
|
|
|
}
|
|
|
-
|
|
|
[[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]];
|
|
|
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
|
|
|
+ [self countUnreadMessage];
|
|
|
}
|
|
|
|
|
|
- (void)initLoginView {
|
|
@@ -813,31 +714,11 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
|
|
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
|
|
|
|
|
|
- RCConnectionStatus status = [[RCIMClient sharedRCIMClient] getConnectionStatus];
|
|
|
- if (status != ConnectionStatus_SignOut) {
|
|
|
- int unreadMsgCount = [[RCIMClient sharedRCIMClient] getUnreadCount:@[@(ConversationType_PRIVATE), @(ConversationType_APPSERVICE), @(ConversationType_GROUP),@(ConversationType_SYSTEM)]];
|
|
|
- application.applicationIconBadgeNumber = unreadMsgCount;
|
|
|
- if (unreadMsgCount >= 1) {
|
|
|
- [self.tabBarController noteNewsWithIndex:2 count:unreadMsgCount];
|
|
|
- } else {
|
|
|
- [self.tabBarController clearNewsWithIndex:2];
|
|
|
- }
|
|
|
- }
|
|
|
+ [self countUnreadMessage];
|
|
|
}
|
|
|
|
|
|
- (void)didReceiveMessageNotification:(NSNotification *)notification {
|
|
|
- NSNumber *left = [notification.userInfo objectForKey:@"left"];
|
|
|
- if ([RCIMClient sharedRCIMClient].sdkRunningMode == RCSDKRunningMode_Background && 0 == left.integerValue) {
|
|
|
- int unreadMsgCount = [[RCIMClient sharedRCIMClient] getUnreadCount:@[@(ConversationType_PRIVATE), @(ConversationType_APPSERVICE), @(ConversationType_GROUP),@(ConversationType_SYSTEM)]];
|
|
|
- dispatch_async(dispatch_get_main_queue(),^{
|
|
|
- [UIApplication sharedApplication].applicationIconBadgeNumber = unreadMsgCount;
|
|
|
- if (unreadMsgCount >= 1) {
|
|
|
- [self.tabBarController noteNewsWithIndex:2 count:unreadMsgCount];
|
|
|
- } else {
|
|
|
- [self.tabBarController clearNewsWithIndex:2];
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (BOOL)handleOutLink:(NSURL *)url {
|
|
@@ -1068,5 +949,44 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 统计消息数量
|
|
|
+- (void)countUnreadMessage {
|
|
|
+ if ([TXIM_LINSENTER isCurrentUserLoginIM]) {
|
|
|
+ [TXIM_LINSENTER getUnReadCountCallback:^(NSInteger count) {
|
|
|
+ dispatch_async(dispatch_get_main_queue(),^{
|
|
|
+ NSLog(@"----- %zd",count);
|
|
|
+ [UIApplication sharedApplication].applicationIconBadgeNumber = count;
|
|
|
+ if (count >= 1) {
|
|
|
+ [self noteIMNewsCount:count];
|
|
|
+ } else {
|
|
|
+ [self clearIMNewsCount];
|
|
|
+ }
|
|
|
+
|
|
|
+ NSDictionary *receiveMsg = @{@"unreadCount":@(count)};
|
|
|
+
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:CHATVIEW_REFRESHSTATUS object:receiveMsg];
|
|
|
+ });
|
|
|
+ }];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)noteIMNewsCount:(NSInteger)count {
|
|
|
+ if ([self.tabBarController isKindOfClass:[KSTabBarViewController class]]) {
|
|
|
+ [self.tabBarController noteNewsWithIndex:2 count:count];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self.tabBarController noteNewsWithIndex:1 count:count];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)clearIMNewsCount {
|
|
|
+ if ([self.tabBarController isKindOfClass:[KSTabBarViewController class]]) {
|
|
|
+ [self.tabBarController clearNewsWithIndex:2];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self.tabBarController clearNewsWithIndex:1];
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
@end
|