File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
ios/RNNeteaseIm/RNNeteaseIm Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ typedef void(^SUCCESS) (id param);
1313typedef void (^ERROR)(NSString *error);
1414@interface NIMViewController : UIViewController
1515
16+ @property (copy , nonatomic ) NSString *strAccount;
17+ @property (copy , nonatomic ) NSString *strToken;
18+
1619+(instancetype )initWithController ;
1720-(instancetype )initWithNIMController ;
1821-(void )deleteCurrentSession : (NSString *)recentContactId andback : (ERROR)error ;
Original file line number Diff line number Diff line change 1010#import " ContactViewController.h"
1111
1212@interface NIMViewController ()<NIMLoginManagerDelegate,NIMConversationManagerDelegate>{
13-
13+ BOOL isLoginFailed;
1414}
1515
1616@end
@@ -51,6 +51,7 @@ - (void)onLogin:(NIMLoginStep)step{
5151 break ;
5252 case NIMLoginStepLinkOK:// 连接服务器成功
5353 strStatus = @" 5" ;
54+ [self backLogin ];
5455 [self getResouces ];
5556 break ;
5657 case NIMLoginStepLinkFailed:// 连接服务器失败
@@ -64,6 +65,7 @@ - (void)onLogin:(NIMLoginStep)step{
6465 break ;
6566 case NIMLoginStepLoginFailed:// 登录失败
6667 strStatus = @" 10" ;
68+ isLoginFailed = YES ;
6769 break ;
6870 case NIMLoginStepSyncing:// 开始同步
6971 strStatus = @" 13" ;
@@ -101,6 +103,17 @@ -(void)deleteCurrentSession:(NSString *)recentContactId andback:(ERROR)error{
101103 }
102104}
103105
106+ // 登录失败后重新手动登录
107+ - (void )backLogin {
108+ if (isLoginFailed) {
109+ isLoginFailed = NO ;
110+ NSLog (@" :%@ :%@ " ,_strAccount,_strToken);
111+ [[NIMSDK sharedSDK ].loginManager login: _strAccount token: _strToken completion: ^(NSError * _Nullable error) {
112+ NSLog (@" error:%@ " ,error);
113+ }];
114+ }
115+ }
116+
104117#pragma NIMLoginManagerDelegate
105118-(void )onKick : (NIMKickReason)code clientType : (NIMLoginClientType)clientType
106119{
Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ - (dispatch_queue_t)methodQueue
9191 NSLog (@" %@ :%@ " ,strEorr,error);
9292 }
9393 }];
94+ [NIMViewController initWithController ].strToken = token;
95+ [NIMViewController initWithController ].strAccount = account;
9496}
9597
9698// 注销用户
You can’t perform that action at this time.
0 commit comments