云信的登录逻辑 被踢

This commit is contained in:
fengshuo
2021-10-21 12:01:21 +08:00
parent 293d3f9f47
commit ddd0dc2c17
14 changed files with 327 additions and 4 deletions

View File

@@ -33,11 +33,12 @@ target 'xplan-ios' do
pod 'BaiduMobStatCodeless', '~> 5.3.5' pod 'BaiduMobStatCodeless', '~> 5.3.5'
#文字自动滚动 #文字自动滚动
pod 'MarqueeLabel-ObjC' pod 'MarqueeLabel-ObjC'
#声网 #声网
pod 'AgoraRtcEngine_iOS', '~> 3.0.1' pod 'AgoraRtcEngine_iOS', '~> 3.0.1'
#pop动画 #pop动画
pod 'pop', '~> 1.0.12' pod 'pop', '~> 1.0.12'
#云信
pod 'NIMSDK_LITE', '~> 7.8.3'
#登录的 #登录的
pod 'mob_sharesdk' pod 'mob_sharesdk'
pod 'mob_sharesdk/ShareSDKPlatforms/QQ' pod 'mob_sharesdk/ShareSDKPlatforms/QQ'

View File

@@ -40,6 +40,7 @@ PODS:
- mob_sharesdk/ShareSDK - mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9) - MOBFoundation (>= 3.2.9)
- MOBFoundation (3.2.27) - MOBFoundation (3.2.27)
- NIMSDK_LITE (7.8.5)
- NTESQuickPass (2.1.9) - NTESQuickPass (2.1.9)
- pop (1.0.12) - pop (1.0.12)
- Qiniu (8.3.2): - Qiniu (8.3.2):
@@ -70,6 +71,7 @@ DEPENDENCIES:
- mob_sharesdk/ShareSDKPlatforms/Apple - mob_sharesdk/ShareSDKPlatforms/Apple
- mob_sharesdk/ShareSDKPlatforms/QQ - mob_sharesdk/ShareSDKPlatforms/QQ
- mob_sharesdk/ShareSDKPlatforms/WeChat - mob_sharesdk/ShareSDKPlatforms/WeChat
- NIMSDK_LITE (~> 7.8.3)
- NTESQuickPass (~> 2.1.6) - NTESQuickPass (~> 2.1.6)
- pop (~> 1.0.12) - pop (~> 1.0.12)
- Qiniu - Qiniu
@@ -96,6 +98,7 @@ SPEC REPOS:
- MJExtension - MJExtension
- mob_sharesdk - mob_sharesdk
- MOBFoundation - MOBFoundation
- NIMSDK_LITE
- NTESQuickPass - NTESQuickPass
- pop - pop
- Qiniu - Qiniu
@@ -121,6 +124,7 @@ SPEC CHECKSUMS:
MJExtension: 01704cca2b60a214c10761b6491eab74069d68a9 MJExtension: 01704cca2b60a214c10761b6491eab74069d68a9
mob_sharesdk: a60006891a079486ff3269ed326adfa05a967c01 mob_sharesdk: a60006891a079486ff3269ed326adfa05a967c01
MOBFoundation: efdc3ce6b843fbc10ae8c1c6122a02b0d845b39b MOBFoundation: efdc3ce6b843fbc10ae8c1c6122a02b0d845b39b
NIMSDK_LITE: 8e28ae0a26dd1dccc4684b697381f0a72a733f51
NTESQuickPass: 8431dc52737c95883cd382c2ee75664d58f39377 NTESQuickPass: 8431dc52737c95883cd382c2ee75664d58f39377
pop: d582054913807fd11fd50bfe6a539d91c7e1a55a pop: d582054913807fd11fd50bfe6a539d91c7e1a55a
Qiniu: 61f1e2fdfb35b37f98c8f03a718faf12652f9994 Qiniu: 61f1e2fdfb35b37f98c8f03a718faf12652f9994
@@ -131,6 +135,6 @@ SPEC CHECKSUMS:
SZTextView: 094dc6acc9beec537685c545d6e3e0d4975174e1 SZTextView: 094dc6acc9beec537685c545d6e3e0d4975174e1
YYText: 5c461d709e24d55a182d1441c41dc639a18a4849 YYText: 5c461d709e24d55a182d1441c41dc639a18a4849
PODFILE CHECKSUM: db33c042062a7ccc33a5468e35a1c606fb3f4e98 PODFILE CHECKSUM: 6968a06e7b791226635261958cf107f1af64fadf
COCOAPODS: 1.10.1 COCOAPODS: 1.10.1

View File

@@ -140,6 +140,10 @@
E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308826E89BE000B90D4F /* LoginPhoneViewController.m */; }; E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308826E89BE000B90D4F /* LoginPhoneViewController.m */; };
E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308C26E89DAA00B90D4F /* LoginInputView.m */; }; E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308C26E89DAA00B90D4F /* LoginInputView.m */; };
E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872309226E8D31500B90D4F /* LoginVerifCodeView.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 */; }; E88B5CA526FB088600DA9178 /* XPMineTeenagerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */; };
E88B5CA826FB089C00DA9178 /* XPMineTeenagePwdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA726FB089C00DA9178 /* XPMineTeenagePwdViewController.m */; }; E88B5CA826FB089C00DA9178 /* XPMineTeenagePwdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA726FB089C00DA9178 /* XPMineTeenagePwdViewController.m */; };
E88B5CAD26FB16A800DA9178 /* XPMineTeenagerDesView.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CAC26FB16A800DA9178 /* XPMineTeenagerDesView.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 = "<group>"; }; E872308C26E89DAA00B90D4F /* LoginInputView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginInputView.m; sourceTree = "<group>"; };
E872309126E8D31500B90D4F /* LoginVerifCodeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginVerifCodeView.h; sourceTree = "<group>"; }; E872309126E8D31500B90D4F /* LoginVerifCodeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginVerifCodeView.h; sourceTree = "<group>"; };
E872309226E8D31500B90D4F /* LoginVerifCodeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginVerifCodeView.m; sourceTree = "<group>"; }; E872309226E8D31500B90D4F /* LoginVerifCodeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginVerifCodeView.m; sourceTree = "<group>"; };
E874B86A272105DD003954B9 /* XPIMManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMManager.h; sourceTree = "<group>"; };
E874B86B272105DD003954B9 /* XPIMManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPIMManager.m; sourceTree = "<group>"; };
E874B86E2721067A003954B9 /* XPIMLoginImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMLoginImpl.h; sourceTree = "<group>"; };
E874B86F2721067A003954B9 /* XPIMLoginImpl.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPIMLoginImpl.m; sourceTree = "<group>"; };
E874B87127210699003954B9 /* XPIMLoginInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMLoginInterface.h; sourceTree = "<group>"; };
E874B872272106B3003954B9 /* XPIMLoginDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMLoginDelegate.h; sourceTree = "<group>"; };
E88B5CA326FB088600DA9178 /* XPMineTeenagerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagerViewController.h; sourceTree = "<group>"; }; E88B5CA326FB088600DA9178 /* XPMineTeenagerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagerViewController.h; sourceTree = "<group>"; };
E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineTeenagerViewController.m; sourceTree = "<group>"; }; E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineTeenagerViewController.m; sourceTree = "<group>"; };
E88B5CA626FB089C00DA9178 /* XPMineTeenagePwdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagePwdViewController.h; sourceTree = "<group>"; }; E88B5CA626FB089C00DA9178 /* XPMineTeenagePwdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagePwdViewController.h; sourceTree = "<group>"; };
@@ -948,6 +958,7 @@
189DD56126DE45F800AB55B1 /* Main */ = { 189DD56126DE45F800AB55B1 /* Main */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E874B869272105C0003954B9 /* IM */,
18486210271EA9A5005FC5DC /* RTC */, 18486210271EA9A5005FC5DC /* RTC */,
E8AEAED3271412D00017FCE0 /* Room */, E8AEAED3271412D00017FCE0 /* Room */,
E8E70D6E26F2EB1200F03460 /* Mine */, E8E70D6E26F2EB1200F03460 /* Mine */,
@@ -1396,6 +1407,27 @@
path = CustomView; path = CustomView;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
E874B869272105C0003954B9 /* IM */ = {
isa = PBXGroup;
children = (
E874B86D2721064E003954B9 /* Login */,
E874B86A272105DD003954B9 /* XPIMManager.h */,
E874B86B272105DD003954B9 /* XPIMManager.m */,
);
path = IM;
sourceTree = "<group>";
};
E874B86D2721064E003954B9 /* Login */ = {
isa = PBXGroup;
children = (
E874B86E2721067A003954B9 /* XPIMLoginImpl.h */,
E874B86F2721067A003954B9 /* XPIMLoginImpl.m */,
E874B87127210699003954B9 /* XPIMLoginInterface.h */,
E874B872272106B3003954B9 /* XPIMLoginDelegate.h */,
);
path = Login;
sourceTree = "<group>";
};
E88B5CA926FB15B900DA9178 /* Teenager */ = { E88B5CA926FB15B900DA9178 /* Teenager */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@@ -1969,6 +2001,8 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
E874B874272108ED003954B9 /* XPIMLoginInterface.h in Sources */,
E874B873272108DB003954B9 /* XPIMLoginDelegate.h in Sources */,
E8B846D826FDE17300A777FE /* XPMineRechargeProtocol.h in Sources */, E8B846D826FDE17300A777FE /* XPMineRechargeProtocol.h in Sources */,
E8B846C726FDB45000A777FE /* XPMineUserInfoAlbumProtocol.h in Sources */, E8B846C726FDB45000A777FE /* XPMineUserInfoAlbumProtocol.h in Sources */,
E8EEB91126FC6AE2007C6EBA /* XPMineUserInfoEditProtocol.h in Sources */, E8EEB91126FC6AE2007C6EBA /* XPMineUserInfoEditProtocol.h in Sources */,
@@ -2022,6 +2056,7 @@
E8EEB8F226FC2050007C6EBA /* SDPhotoBrowser.m in Sources */, E8EEB8F226FC2050007C6EBA /* SDPhotoBrowser.m in Sources */,
E89DA67827009F16008483C1 /* NSObject+JSONString.m in Sources */, E89DA67827009F16008483C1 /* NSObject+JSONString.m in Sources */,
E81C27AB26EF2D920031E639 /* ThirdUserInfo.m in Sources */, E81C27AB26EF2D920031E639 /* ThirdUserInfo.m in Sources */,
E874B86C272105DD003954B9 /* XPIMManager.m in Sources */,
E81C279D26EEEC620031E639 /* XPConstant.m in Sources */, E81C279D26EEEC620031E639 /* XPConstant.m in Sources */,
187EEEFE26E8A82C002833B2 /* NSObject+AutoCoding.m in Sources */, 187EEEFE26E8A82C002833B2 /* NSObject+AutoCoding.m in Sources */,
E8AC721926F46E0B007D6E91 /* XPMineSettingItemModel.m in Sources */, E8AC721926F46E0B007D6E91 /* XPMineSettingItemModel.m in Sources */,
@@ -2091,6 +2126,7 @@
E8E70D7726F2F15100F03460 /* XPMineViewController.m in Sources */, E8E70D7726F2F15100F03460 /* XPMineViewController.m in Sources */,
E8AC722C26F49580007D6E91 /* XPMineNotificaViewController.m in Sources */, E8AC722C26F49580007D6E91 /* XPMineNotificaViewController.m in Sources */,
189DD52E26DE255300AB55B1 /* AppDelegate.m in Sources */, 189DD52E26DE255300AB55B1 /* AppDelegate.m in Sources */,
E874B8702721067A003954B9 /* XPIMLoginImpl.m in Sources */,
E88F5EB0271ECEF000FF9B33 /* XPRoomViewController+RoomInfoContainerView.m in Sources */, E88F5EB0271ECEF000FF9B33 /* XPRoomViewController+RoomInfoContainerView.m in Sources */,
E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */, E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */,
E8E70D8C26F2F5A500F03460 /* XPMineMatchCollectionViewCell.m in Sources */, E8E70D8C26F2F5A500F03460 /* XPMineMatchCollectionViewCell.m in Sources */,

View File

@@ -8,6 +8,7 @@
#import "AppDelegate+ThirdConfig.h" #import "AppDelegate+ThirdConfig.h"
///Third ///Third
#import <ShareSDK/ShareSDK.h> #import <ShareSDK/ShareSDK.h>
#import <NIMSDK/NIMSDK.h>
///Tool ///Tool
#import "XPConstant.h" #import "XPConstant.h"
@@ -17,6 +18,7 @@
/// ///
- (void)initThirdConfig { - (void)initThirdConfig {
[self configShareSDK]; [self configShareSDK];
[self configNIMSDK];
} }
- (void)configShareSDK { - (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 @end

View File

@@ -23,6 +23,8 @@ typedef NS_ENUM(NSUInteger, KeyType) {
KeyType_WechatAppid,///微信的 appid KeyType_WechatAppid,///微信的 appid
KeyType_WechatSecret,///微信的 secret KeyType_WechatSecret,///微信的 secret
KeyType_Agora,///声网 key KeyType_Agora,///声网 key
KeyType_NetEase,///云信的key
KeyType_APNSCer,///推送证书的名字
}; };
/// 获取当前项目中所用到的 type 所对应的 value 的值 type 类型 /// 获取当前项目中所用到的 type 所对应的 value 的值 type 类型

View File

@@ -15,7 +15,8 @@ NSString * const kWeChatNumber = @"yinyoucc";
/// ///
NSString * const KeyWithType(KeyType type) { NSString * const KeyWithType(KeyType type) {
BOOL isRelease = YES; #warning to do
BOOL isRelease = NO;
NSDictionary * dic = @{ NSDictionary * dic = @{
/// ///
@(YES):@{ @(YES):@{
@@ -26,6 +27,8 @@ NSString * const KeyWithType(KeyType type) {
@(KeyType_WechatAppid) : @"wx3f0462eb7eccd64f", @(KeyType_WechatAppid) : @"wx3f0462eb7eccd64f",
@(KeyType_WechatSecret) : @"1c07949e3f53433f1c6038bfcdd54c40", @(KeyType_WechatSecret) : @"1c07949e3f53433f1c6038bfcdd54c40",
@(KeyType_Agora) : @"7ae1a8dabe7a44a9a67c829faa409e70", @(KeyType_Agora) : @"7ae1a8dabe7a44a9a67c829faa409e70",
@(KeyType_NetEase) : @"14ef7a0d0a84cb49bae1c22d78cf1ddf",
@(KeyType_APNSCer) : @"yinyouApnsRelease",
}, },
/// ///
@(NO):@{ @(NO):@{
@@ -36,6 +39,8 @@ NSString * const KeyWithType(KeyType type) {
@(KeyType_WechatAppid) : @"wx3f0462eb7eccd64f", @(KeyType_WechatAppid) : @"wx3f0462eb7eccd64f",
@(KeyType_WechatSecret) : @"1c07949e3f53433f1c6038bfcdd54c40", @(KeyType_WechatSecret) : @"1c07949e3f53433f1c6038bfcdd54c40",
@(KeyType_Agora) : @"7ae1a8dabe7a44a9a67c829faa409e70", @(KeyType_Agora) : @"7ae1a8dabe7a44a9a67c829faa409e70",
@(KeyType_NetEase) : @"82a8d602aacbbb27a1c0fc809052286e",
@(KeyType_APNSCer) : @"yinyouApnsDebug",
} }
}; };
NSDictionary * enviroDic = [dic objectForKey:@(isRelease)]; NSDictionary * enviroDic = [dic objectForKey:@(isRelease)];

View File

@@ -0,0 +1,27 @@
//
// XPIMLoginDelegate.h
// xplan-ios
//
// Created by 冯硕 on 2021/10/21.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol XPIMLoginDelegate <NSObject>
@optional
///云信登录成功
- (void)imLoginSuccess;
///云信数据同步成功
- (void)imSyncSuccess;
///云信登录失败
- (void)imLoginFail;
/// 被踢(服务器/其他端)回调
- (void)imKickOut:(NSString*)reason;
///退出登录成功
- (void)imLogoutSuccess;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,16 @@
//
// XPIMLoginImpl.h
// xplan-ios
//
// Created by 冯硕 on 2021/10/21.
//
#import <Foundation/Foundation.h>
#import "XPIMLoginInterface.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPIMLoginImpl : NSObject<XPIMLoginInterface>
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,119 @@
//
// XPIMLoginImpl.m
// xplan-ios
//
// Created by on 2021/10/21.
//
#import "XPIMLoginImpl.h"
///Third
#import <NIMSDK/NIMSDK.h>
///P
#import "XPIMLoginDelegate.h"
///Tool
@interface XPIMLoginImpl ()<XPIMLoginInterface, NIMLoginManagerDelegate>
///
@property (nonatomic,strong) id<XPIMLoginDelegate> 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<XPIMLoginDelegate>)delegate {
self.delegate = delegate;
}
- (void)removeDelegate:(id<XPIMLoginDelegate>)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

View File

@@ -0,0 +1,23 @@
//
// XPIMLoginInterface.h
// xplan-ios
//
// Created by 冯硕 on 2021/10/21.
//
#import <Foundation/Foundation.h>
#import "XPIMLoginDelegate.h"
NS_ASSUME_NONNULL_BEGIN
@protocol XPIMLoginInterface <NSObject>
///自动登录
- (void)autoLoginIm:(NSString *)account token:(NSString *)token;
///退出登录im
- (void)logoutIm;
///添加代理
- (void)addDelegate:(id<XPIMLoginDelegate>)delegate;
///移除代理
- (void)removeDelegate:(id<XPIMLoginDelegate>)delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,19 @@
//
// XPIMManager.h
// xplan-ios
//
// Created by 冯硕 on 2021/10/21.
//
#import <Foundation/Foundation.h>
#import "XPIMLoginInterface.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPIMManager : NSObject
+ (instancetype)shareManager;
///im登录的协议
@property (nonatomic,strong, readonly) id<XPIMLoginInterface> imLoginManager;
@end
NS_ASSUME_NONNULL_END

View File

@@ -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<XPIMLoginInterface> imLoginManager;
@end
@implementation XPIMManager
+ (instancetype)shareManager {
static dispatch_once_t onceToken;
static XPIMManager * manager;
dispatch_once(&onceToken, ^{
manager = [[XPIMManager alloc] init];
});
return manager;
}
- (id<XPIMLoginInterface>)imLoginManager {
if (!_imLoginManager) {
_imLoginManager = [[XPIMLoginImpl alloc] init];
}
return _imLoginManager;
}
@end

View File

@@ -69,6 +69,7 @@
_engineDelegate = delegate; _engineDelegate = delegate;
} }
- (id<RtcInterface>)engine { - (id<RtcInterface>)engine {
if (!_engine) { if (!_engine) {
switch (_engineType) { switch (_engineType) {

View File

@@ -7,6 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
///Third ///Third
#import <flutter_boost/FlutterBoost.h> #import <flutter_boost/FlutterBoost.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool ///Tool
#import "XPMacro.h" #import "XPMacro.h"
#import "ThemeColor.h" #import "ThemeColor.h"
@@ -14,6 +15,9 @@
#import "XCHUDTool.h" #import "XCHUDTool.h"
#import "RechargeStorage.h" #import "RechargeStorage.h"
#import "AccountInfoStorage.h" #import "AccountInfoStorage.h"
#import "XPIMManager.h"
///Model
#import "AccountModel.h"
///VC ///VC
#import "TabbarViewController.h" #import "TabbarViewController.h"
#import "BaseViewController.h" #import "BaseViewController.h"
@@ -26,10 +30,11 @@
///Present ///Present
#import "MainPresenter.h" #import "MainPresenter.h"
#import "MainProtocol.h" #import "MainProtocol.h"
#import "XPIMLoginDelegate.h"
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol> @interface TabbarViewController () <BaseMvpProtocol, MainProtocol, XPIMLoginDelegate>
@property (nonatomic, strong) MainPresenter *presenter; @property (nonatomic, strong) MainPresenter *presenter;
@@ -37,10 +42,15 @@
@implementation TabbarViewController @implementation TabbarViewController
- (void)dealloc {
[[XPIMManager shareManager].imLoginManager removeDelegate:self];
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self configTheme]; [self configTheme];
[self initTabs:NO]; [self initTabs:NO];
[self configImDelegate];
} }
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
@@ -100,6 +110,12 @@
[RechargeStorage delegateAllTranscationIdsWithUid:uid]; [RechargeStorage delegateAllTranscationIdsWithUid:uid];
} }
#pragma mark - XPIMLoginDelegate
///
- (void)imKickOut:(NSString *)reason {
[self tokenInvalid];
}
#pragma mark - #pragma mark -
- (void)checkTranscationIds { - (void)checkTranscationIds {
NSString * uid = [AccountInfoStorage instance].getUid; NSString * uid = [AccountInfoStorage instance].getUid;
@@ -117,6 +133,16 @@
[self.navigationController presentViewController:nav animated:YES completion:nil]; [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 { - (void)configTheme {
[[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[ThemeColor appCellBackgroundColor] size:CGSizeMake(KScreenWidth, kTabBarHeight)]]; [[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[ThemeColor appCellBackgroundColor] size:CGSizeMake(KScreenWidth, kTabBarHeight)]];
[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]]; [[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];