From ddd0dc2c17cb7859e722d551dea568887af71d71 Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Thu, 21 Oct 2021 12:01:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=91=E4=BF=A1=E7=9A=84=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=80=BB=E8=BE=91=20=E8=A2=AB=E8=B8=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Podfile | 3 +- Podfile.lock | 6 +- xplan-ios.xcodeproj/project.pbxproj | 36 ++++++ .../Appdelegate/AppDelegate+ThirdConfig.m | 10 ++ xplan-ios/Global/XPConstant.h | 2 + xplan-ios/Global/XPConstant.m | 7 +- xplan-ios/Main/IM/Login/XPIMLoginDelegate.h | 27 ++++ xplan-ios/Main/IM/Login/XPIMLoginImpl.h | 16 +++ xplan-ios/Main/IM/Login/XPIMLoginImpl.m | 119 ++++++++++++++++++ xplan-ios/Main/IM/Login/XPIMLoginInterface.h | 23 ++++ xplan-ios/Main/IM/XPIMManager.h | 19 +++ xplan-ios/Main/IM/XPIMManager.m | 34 +++++ xplan-ios/Main/RTC/RtcManager.m | 1 + xplan-ios/Main/Tabbar/TabbarViewController.m | 28 ++++- 14 files changed, 327 insertions(+), 4 deletions(-) create mode 100644 xplan-ios/Main/IM/Login/XPIMLoginDelegate.h create mode 100644 xplan-ios/Main/IM/Login/XPIMLoginImpl.h create mode 100644 xplan-ios/Main/IM/Login/XPIMLoginImpl.m create mode 100644 xplan-ios/Main/IM/Login/XPIMLoginInterface.h create mode 100644 xplan-ios/Main/IM/XPIMManager.h create mode 100644 xplan-ios/Main/IM/XPIMManager.m diff --git a/Podfile b/Podfile index c53f78a2..5c213a98 100644 --- a/Podfile +++ b/Podfile @@ -33,11 +33,12 @@ target 'xplan-ios' do pod 'BaiduMobStatCodeless', '~> 5.3.5' #文字自动滚动 pod 'MarqueeLabel-ObjC' - #声网 pod 'AgoraRtcEngine_iOS', '~> 3.0.1' #pop动画 pod 'pop', '~> 1.0.12' + #云信 + pod 'NIMSDK_LITE', '~> 7.8.3' #登录的 pod 'mob_sharesdk' pod 'mob_sharesdk/ShareSDKPlatforms/QQ' diff --git a/Podfile.lock b/Podfile.lock index 8b2ab606..c72021c6 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -40,6 +40,7 @@ PODS: - mob_sharesdk/ShareSDK - MOBFoundation (>= 3.2.9) - MOBFoundation (3.2.27) + - NIMSDK_LITE (7.8.5) - NTESQuickPass (2.1.9) - pop (1.0.12) - Qiniu (8.3.2): @@ -70,6 +71,7 @@ DEPENDENCIES: - mob_sharesdk/ShareSDKPlatforms/Apple - mob_sharesdk/ShareSDKPlatforms/QQ - mob_sharesdk/ShareSDKPlatforms/WeChat + - NIMSDK_LITE (~> 7.8.3) - NTESQuickPass (~> 2.1.6) - pop (~> 1.0.12) - Qiniu @@ -96,6 +98,7 @@ SPEC REPOS: - MJExtension - mob_sharesdk - MOBFoundation + - NIMSDK_LITE - NTESQuickPass - pop - Qiniu @@ -121,6 +124,7 @@ SPEC CHECKSUMS: MJExtension: 01704cca2b60a214c10761b6491eab74069d68a9 mob_sharesdk: a60006891a079486ff3269ed326adfa05a967c01 MOBFoundation: efdc3ce6b843fbc10ae8c1c6122a02b0d845b39b + NIMSDK_LITE: 8e28ae0a26dd1dccc4684b697381f0a72a733f51 NTESQuickPass: 8431dc52737c95883cd382c2ee75664d58f39377 pop: d582054913807fd11fd50bfe6a539d91c7e1a55a Qiniu: 61f1e2fdfb35b37f98c8f03a718faf12652f9994 @@ -131,6 +135,6 @@ SPEC CHECKSUMS: SZTextView: 094dc6acc9beec537685c545d6e3e0d4975174e1 YYText: 5c461d709e24d55a182d1441c41dc639a18a4849 -PODFILE CHECKSUM: db33c042062a7ccc33a5468e35a1c606fb3f4e98 +PODFILE CHECKSUM: 6968a06e7b791226635261958cf107f1af64fadf COCOAPODS: 1.10.1 diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index a6915adc..7b1427d3 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -140,6 +140,10 @@ E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308826E89BE000B90D4F /* LoginPhoneViewController.m */; }; E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308C26E89DAA00B90D4F /* LoginInputView.m */; }; E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872309226E8D31500B90D4F /* LoginVerifCodeView.m */; }; + E874B86C272105DD003954B9 /* XPIMManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E874B86B272105DD003954B9 /* XPIMManager.m */; }; + E874B8702721067A003954B9 /* XPIMLoginImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = E874B86F2721067A003954B9 /* XPIMLoginImpl.m */; }; + E874B873272108DB003954B9 /* XPIMLoginDelegate.h in Sources */ = {isa = PBXBuildFile; fileRef = E874B872272106B3003954B9 /* XPIMLoginDelegate.h */; }; + E874B874272108ED003954B9 /* XPIMLoginInterface.h in Sources */ = {isa = PBXBuildFile; fileRef = E874B87127210699003954B9 /* XPIMLoginInterface.h */; }; E88B5CA526FB088600DA9178 /* XPMineTeenagerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */; }; E88B5CA826FB089C00DA9178 /* XPMineTeenagePwdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA726FB089C00DA9178 /* XPMineTeenagePwdViewController.m */; }; E88B5CAD26FB16A800DA9178 /* XPMineTeenagerDesView.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CAC26FB16A800DA9178 /* XPMineTeenagerDesView.m */; }; @@ -491,6 +495,12 @@ E872308C26E89DAA00B90D4F /* LoginInputView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginInputView.m; sourceTree = ""; }; E872309126E8D31500B90D4F /* LoginVerifCodeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginVerifCodeView.h; sourceTree = ""; }; E872309226E8D31500B90D4F /* LoginVerifCodeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginVerifCodeView.m; sourceTree = ""; }; + E874B86A272105DD003954B9 /* XPIMManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMManager.h; sourceTree = ""; }; + E874B86B272105DD003954B9 /* XPIMManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPIMManager.m; sourceTree = ""; }; + E874B86E2721067A003954B9 /* XPIMLoginImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMLoginImpl.h; sourceTree = ""; }; + E874B86F2721067A003954B9 /* XPIMLoginImpl.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPIMLoginImpl.m; sourceTree = ""; }; + E874B87127210699003954B9 /* XPIMLoginInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMLoginInterface.h; sourceTree = ""; }; + E874B872272106B3003954B9 /* XPIMLoginDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMLoginDelegate.h; sourceTree = ""; }; E88B5CA326FB088600DA9178 /* XPMineTeenagerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagerViewController.h; sourceTree = ""; }; E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineTeenagerViewController.m; sourceTree = ""; }; E88B5CA626FB089C00DA9178 /* XPMineTeenagePwdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagePwdViewController.h; sourceTree = ""; }; @@ -948,6 +958,7 @@ 189DD56126DE45F800AB55B1 /* Main */ = { isa = PBXGroup; children = ( + E874B869272105C0003954B9 /* IM */, 18486210271EA9A5005FC5DC /* RTC */, E8AEAED3271412D00017FCE0 /* Room */, E8E70D6E26F2EB1200F03460 /* Mine */, @@ -1396,6 +1407,27 @@ path = CustomView; sourceTree = ""; }; + E874B869272105C0003954B9 /* IM */ = { + isa = PBXGroup; + children = ( + E874B86D2721064E003954B9 /* Login */, + E874B86A272105DD003954B9 /* XPIMManager.h */, + E874B86B272105DD003954B9 /* XPIMManager.m */, + ); + path = IM; + sourceTree = ""; + }; + E874B86D2721064E003954B9 /* Login */ = { + isa = PBXGroup; + children = ( + E874B86E2721067A003954B9 /* XPIMLoginImpl.h */, + E874B86F2721067A003954B9 /* XPIMLoginImpl.m */, + E874B87127210699003954B9 /* XPIMLoginInterface.h */, + E874B872272106B3003954B9 /* XPIMLoginDelegate.h */, + ); + path = Login; + sourceTree = ""; + }; E88B5CA926FB15B900DA9178 /* Teenager */ = { isa = PBXGroup; children = ( @@ -1969,6 +2001,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + E874B874272108ED003954B9 /* XPIMLoginInterface.h in Sources */, + E874B873272108DB003954B9 /* XPIMLoginDelegate.h in Sources */, E8B846D826FDE17300A777FE /* XPMineRechargeProtocol.h in Sources */, E8B846C726FDB45000A777FE /* XPMineUserInfoAlbumProtocol.h in Sources */, E8EEB91126FC6AE2007C6EBA /* XPMineUserInfoEditProtocol.h in Sources */, @@ -2022,6 +2056,7 @@ E8EEB8F226FC2050007C6EBA /* SDPhotoBrowser.m in Sources */, E89DA67827009F16008483C1 /* NSObject+JSONString.m in Sources */, E81C27AB26EF2D920031E639 /* ThirdUserInfo.m in Sources */, + E874B86C272105DD003954B9 /* XPIMManager.m in Sources */, E81C279D26EEEC620031E639 /* XPConstant.m in Sources */, 187EEEFE26E8A82C002833B2 /* NSObject+AutoCoding.m in Sources */, E8AC721926F46E0B007D6E91 /* XPMineSettingItemModel.m in Sources */, @@ -2091,6 +2126,7 @@ E8E70D7726F2F15100F03460 /* XPMineViewController.m in Sources */, E8AC722C26F49580007D6E91 /* XPMineNotificaViewController.m in Sources */, 189DD52E26DE255300AB55B1 /* AppDelegate.m in Sources */, + E874B8702721067A003954B9 /* XPIMLoginImpl.m in Sources */, E88F5EB0271ECEF000FF9B33 /* XPRoomViewController+RoomInfoContainerView.m in Sources */, E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */, E8E70D8C26F2F5A500F03460 /* XPMineMatchCollectionViewCell.m in Sources */, diff --git a/xplan-ios/Appdelegate/AppDelegate+ThirdConfig.m b/xplan-ios/Appdelegate/AppDelegate+ThirdConfig.m index ccfc53dd..c780037a 100644 --- a/xplan-ios/Appdelegate/AppDelegate+ThirdConfig.m +++ b/xplan-ios/Appdelegate/AppDelegate+ThirdConfig.m @@ -8,6 +8,7 @@ #import "AppDelegate+ThirdConfig.h" ///Third #import +#import ///Tool #import "XPConstant.h" @@ -17,6 +18,7 @@ /// 初始化一些第三方配置 - (void)initThirdConfig { [self configShareSDK]; + [self configNIMSDK]; } - (void)configShareSDK { @@ -29,4 +31,12 @@ }]; } +- (void)configNIMSDK { + //推荐在程序启动的时候初始化 NIMSDK + NSString *appKey = KeyWithType(KeyType_NetEase); + NIMSDKOption *option = [NIMSDKOption optionWithAppKey:appKey]; + option.apnsCername = KeyWithType(KeyType_APNSCer); + [[NIMSDK sharedSDK] registerWithOption:option]; +} + @end diff --git a/xplan-ios/Global/XPConstant.h b/xplan-ios/Global/XPConstant.h index 643ecf61..f55ce760 100644 --- a/xplan-ios/Global/XPConstant.h +++ b/xplan-ios/Global/XPConstant.h @@ -23,6 +23,8 @@ typedef NS_ENUM(NSUInteger, KeyType) { KeyType_WechatAppid,///微信的 appid KeyType_WechatSecret,///微信的 secret KeyType_Agora,///声网 key + KeyType_NetEase,///云信的key + KeyType_APNSCer,///推送证书的名字 }; /// 获取当前项目中所用到的 type 所对应的 value 的值 type 类型 diff --git a/xplan-ios/Global/XPConstant.m b/xplan-ios/Global/XPConstant.m index da26bbce..519bb9f7 100644 --- a/xplan-ios/Global/XPConstant.m +++ b/xplan-ios/Global/XPConstant.m @@ -15,7 +15,8 @@ NSString * const kWeChatNumber = @"yinyoucc"; ///在里面进行判断当前环境是什么 NSString * const KeyWithType(KeyType type) { - BOOL isRelease = YES; +#warning to do 需要根据当前环境进行判断 + BOOL isRelease = NO; NSDictionary * dic = @{ ///正式环境 @(YES):@{ @@ -26,6 +27,8 @@ NSString * const KeyWithType(KeyType type) { @(KeyType_WechatAppid) : @"wx3f0462eb7eccd64f", @(KeyType_WechatSecret) : @"1c07949e3f53433f1c6038bfcdd54c40", @(KeyType_Agora) : @"7ae1a8dabe7a44a9a67c829faa409e70", + @(KeyType_NetEase) : @"14ef7a0d0a84cb49bae1c22d78cf1ddf", + @(KeyType_APNSCer) : @"yinyouApnsRelease", }, ///测试环境 @(NO):@{ @@ -36,6 +39,8 @@ NSString * const KeyWithType(KeyType type) { @(KeyType_WechatAppid) : @"wx3f0462eb7eccd64f", @(KeyType_WechatSecret) : @"1c07949e3f53433f1c6038bfcdd54c40", @(KeyType_Agora) : @"7ae1a8dabe7a44a9a67c829faa409e70", + @(KeyType_NetEase) : @"82a8d602aacbbb27a1c0fc809052286e", + @(KeyType_APNSCer) : @"yinyouApnsDebug", } }; NSDictionary * enviroDic = [dic objectForKey:@(isRelease)]; diff --git a/xplan-ios/Main/IM/Login/XPIMLoginDelegate.h b/xplan-ios/Main/IM/Login/XPIMLoginDelegate.h new file mode 100644 index 00000000..f75a5971 --- /dev/null +++ b/xplan-ios/Main/IM/Login/XPIMLoginDelegate.h @@ -0,0 +1,27 @@ +// +// XPIMLoginDelegate.h +// xplan-ios +// +// Created by 冯硕 on 2021/10/21. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol XPIMLoginDelegate +@optional +///云信登录成功 +- (void)imLoginSuccess; +///云信数据同步成功 +- (void)imSyncSuccess; +///云信登录失败 +- (void)imLoginFail; +/// 被踢(服务器/其他端)回调 +- (void)imKickOut:(NSString*)reason; +///退出登录成功 +- (void)imLogoutSuccess; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/IM/Login/XPIMLoginImpl.h b/xplan-ios/Main/IM/Login/XPIMLoginImpl.h new file mode 100644 index 00000000..571ea7da --- /dev/null +++ b/xplan-ios/Main/IM/Login/XPIMLoginImpl.h @@ -0,0 +1,16 @@ +// +// XPIMLoginImpl.h +// xplan-ios +// +// Created by 冯硕 on 2021/10/21. +// + +#import +#import "XPIMLoginInterface.h" +NS_ASSUME_NONNULL_BEGIN + +@interface XPIMLoginImpl : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/IM/Login/XPIMLoginImpl.m b/xplan-ios/Main/IM/Login/XPIMLoginImpl.m new file mode 100644 index 00000000..68b1fd50 --- /dev/null +++ b/xplan-ios/Main/IM/Login/XPIMLoginImpl.m @@ -0,0 +1,119 @@ +// +// XPIMLoginImpl.m +// xplan-ios +// +// Created by 冯硕 on 2021/10/21. +// + +#import "XPIMLoginImpl.h" +///Third +#import +///P +#import "XPIMLoginDelegate.h" +///Tool + +@interface XPIMLoginImpl () +///回调的代理 +@property (nonatomic,strong) id delegate; +///账号id +@property (nonatomic,copy) NSString *account; +///token +@property (nonatomic,copy) NSString *token; +@end + +@implementation XPIMLoginImpl +- (instancetype)init { + self = [super init]; + if (self) { + [[NIMSDK sharedSDK].loginManager addDelegate:self]; + } + return self; +} + + +#pragma mark - Private Method +///是否可以响应某个方法 +- (BOOL)canRespondsToSelector:(SEL)aSelector{ + if (self.delegate && [self.delegate respondsToSelector:aSelector]){ + return YES; + } + return NO; +} + +#pragma mark - XPIMLoginInterface +- (void)autoLoginIm:(NSString *)account token:(NSString *)token { + self.account = account; + self.token = token; + NIMAutoLoginData *data = [[NIMAutoLoginData alloc] init]; + data.account = account; + data.token = token; + data.forcedMode = NO; + [[NIMSDK sharedSDK].loginManager autoLogin:data]; +} + +- (void)logoutIm { + [[NIMSDK sharedSDK].loginManager logout:^(NSError * _Nullable error) { + if (error == nil) { + self.account = nil; + self.token = nil; + if ([self canRespondsToSelector:@selector(imLogoutSuccess)]) { + [self.delegate imLogoutSuccess]; + }; + } else { + + } + }]; +} + +- (void)addDelegate:(id)delegate { + self.delegate = delegate; +} + +- (void)removeDelegate:(id)delegate { + self.delegate = nil; + [[NIMSDK sharedSDK].loginManager removeDelegate:self]; +} + +#pragma mark - NIMLoginManagerDelegate +/// 登录的回调 +/// @param step 登录是否成功 +- (void)onLogin:(NIMLoginStep)step{ + if (step == NIMLoginStepLoginOK) { + // 云信登录成功 + if ([self canRespondsToSelector:@selector(imLoginSuccess)] ) { + [self.delegate imLoginSuccess]; + } + } else if (step == NIMLoginStepSyncOK) { + if ([self canRespondsToSelector:@selector(imSyncSuccess)]) { + [self.delegate imSyncSuccess]; + } + } +} + +/// 自动登录失败 +/// @param error 失败的erro +- (void)onAutoLoginFailed:(NSError *)error{ + ///服务器将检查当前登录设备是否为上一次登录设备,如果不是,服务器将拒绝这次自动登录(返回 error code 为 417 的错误);强制模式下的自动登录,服务器将不检查当前登录设备是否为上一次登录设备,安全性较低,但较为便捷。 + if (error.code == 417) { + [[NIMSDK sharedSDK].loginManager login:self.account token:self.token completion:^(NSError * _Nullable error) { + if (error == nil) { + [self.delegate imLoginFail]; + } + }]; + return; + } + if ([self canRespondsToSelector:@selector(imLoginFail)]) { + [self.delegate imLoginFail]; + } +} + +/// 被踢(服务器/其他端)回调 +/// @param result 被踢的原因 +- (void)onKickout:(NIMLoginKickoutResult *)result { + if ([self canRespondsToSelector:@selector(imKickOut:)]) { + [self.delegate imKickOut:result.reasonDesc]; + } +} + + +@end diff --git a/xplan-ios/Main/IM/Login/XPIMLoginInterface.h b/xplan-ios/Main/IM/Login/XPIMLoginInterface.h new file mode 100644 index 00000000..1238c63d --- /dev/null +++ b/xplan-ios/Main/IM/Login/XPIMLoginInterface.h @@ -0,0 +1,23 @@ +// +// XPIMLoginInterface.h +// xplan-ios +// +// Created by 冯硕 on 2021/10/21. +// + +#import +#import "XPIMLoginDelegate.h" +NS_ASSUME_NONNULL_BEGIN + +@protocol XPIMLoginInterface +///自动登录 +- (void)autoLoginIm:(NSString *)account token:(NSString *)token; +///退出登录im +- (void)logoutIm; +///添加代理 +- (void)addDelegate:(id)delegate; +///移除代理 +- (void)removeDelegate:(id)delegate; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/IM/XPIMManager.h b/xplan-ios/Main/IM/XPIMManager.h new file mode 100644 index 00000000..ddcfecd1 --- /dev/null +++ b/xplan-ios/Main/IM/XPIMManager.h @@ -0,0 +1,19 @@ +// +// XPIMManager.h +// xplan-ios +// +// Created by 冯硕 on 2021/10/21. +// + +#import +#import "XPIMLoginInterface.h" +NS_ASSUME_NONNULL_BEGIN + +@interface XPIMManager : NSObject ++ (instancetype)shareManager; +///im登录的协议 +@property (nonatomic,strong, readonly) id imLoginManager; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/IM/XPIMManager.m b/xplan-ios/Main/IM/XPIMManager.m new file mode 100644 index 00000000..a5d59fd4 --- /dev/null +++ b/xplan-ios/Main/IM/XPIMManager.m @@ -0,0 +1,34 @@ +// +// XPIMManager.m +// xplan-ios +// +// Created by 冯硕 on 2021/10/21. +// + +#import "XPIMManager.h" +#import "XPIMLoginImpl.h" +@interface XPIMManager () +/// +@property (nonatomic,strong) id imLoginManager; +@end + +@implementation XPIMManager + ++ (instancetype)shareManager { + static dispatch_once_t onceToken; + static XPIMManager * manager; + dispatch_once(&onceToken, ^{ + manager = [[XPIMManager alloc] init]; + }); + return manager; +} + + +- (id)imLoginManager { + if (!_imLoginManager) { + _imLoginManager = [[XPIMLoginImpl alloc] init]; + } + return _imLoginManager; +} + +@end diff --git a/xplan-ios/Main/RTC/RtcManager.m b/xplan-ios/Main/RTC/RtcManager.m index 94dd18b1..d18264c2 100644 --- a/xplan-ios/Main/RTC/RtcManager.m +++ b/xplan-ios/Main/RTC/RtcManager.m @@ -69,6 +69,7 @@ _engineDelegate = delegate; } + - (id)engine { if (!_engine) { switch (_engineType) { diff --git a/xplan-ios/Main/Tabbar/TabbarViewController.m b/xplan-ios/Main/Tabbar/TabbarViewController.m index 7431131e..bd64d484 100644 --- a/xplan-ios/Main/Tabbar/TabbarViewController.m +++ b/xplan-ios/Main/Tabbar/TabbarViewController.m @@ -7,6 +7,7 @@ #import ///Third #import +#import ///Tool #import "XPMacro.h" #import "ThemeColor.h" @@ -14,6 +15,9 @@ #import "XCHUDTool.h" #import "RechargeStorage.h" #import "AccountInfoStorage.h" +#import "XPIMManager.h" +///Model +#import "AccountModel.h" ///VC #import "TabbarViewController.h" #import "BaseViewController.h" @@ -26,10 +30,11 @@ ///Present #import "MainPresenter.h" #import "MainProtocol.h" +#import "XPIMLoginDelegate.h" -@interface TabbarViewController () +@interface TabbarViewController () @property (nonatomic, strong) MainPresenter *presenter; @@ -37,10 +42,15 @@ @implementation TabbarViewController +- (void)dealloc { + [[XPIMManager shareManager].imLoginManager removeDelegate:self]; +} + - (void)viewDidLoad { [super viewDidLoad]; [self configTheme]; [self initTabs:NO]; + [self configImDelegate]; } - (void)viewWillAppear:(BOOL)animated { @@ -100,6 +110,12 @@ [RechargeStorage delegateAllTranscationIdsWithUid:uid]; } +#pragma mark - XPIMLoginDelegate +///用户被踢 +- (void)imKickOut:(NSString *)reason { + [self tokenInvalid]; +} + #pragma mark - 批量验证内购凭据 - (void)checkTranscationIds { NSString * uid = [AccountInfoStorage instance].getUid; @@ -117,6 +133,16 @@ [self.navigationController presentViewController:nav animated:YES completion:nil]; } +- (void)configImDelegate { + [[XPIMManager shareManager].imLoginManager addDelegate:self]; + [RACObserve([AccountInfoStorage instance], accountModel) subscribeNext:^(id _Nullable x) { + if (x) { + AccountModel * model = x; + [[XPIMManager shareManager].imLoginManager autoLoginIm:model.uid token:model.netEaseToken]; + } + }]; +} + - (void)configTheme { [[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[ThemeColor appCellBackgroundColor] size:CGSizeMake(KScreenWidth, kTabBarHeight)]]; [[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];