qunarcorp/imsdk-ios

登录成功或失败后有监听函数或回调吗

hanwanjie853710069 opened this issue · 7 comments

登录成功或失败后有监听函数或回调吗

/**
用户登录

@param userName 用户名
@param pwd 用户密码
*/

  • (void)loginWithUserName:(NSString *)userName WithPassWord:(NSString *)pwd;

按照文档配置完导航成功后调用改登录接口,但是未找到登录成功或失败后的回调或函数监听

#define kAppWorkStateChange @"kAppWorkStateChange" 可以注册这个字符串的通知 监听App登录状态

App状态 可参见该枚举
typedef enum {
AppWorkState_Logout = 0,
AppWorkState_Logining = 1,
AppWorkState_Updating = 2,
AppWorkState_Login = 3,
AppWorkState_NotNetwork = 4,
AppWorkState_NetworkNotWork = 5,
AppWorkState_ReLogining = 6,
AppWorkState_Upgrading = 7, //升级数据中
} AppWorkState;

PS:问题可以提到对应的 https://github.com/startalkIM/imsdk-ios/issues 看看是否对你有帮助

#import "QIMSDK.h"
...
[QIMSDKUIHelper sharedInstanceWithRootNav:rootNav rootVc:rootVc];
...
BOOL success = [[QIMKit sharedInstance] qimNav_updateNavigationConfigWithDomain:@"qim.com" WithUserName:@"san.zhang"];
if (success = YES) {
[[QIMKit sharedInstance] loginWithUserName:userName WithPassWord:userPwd];
} else {

}
...
UIView *sessionView = [[QIMSDKUIHelper sharedInstance] getQIMSessionListViewWithBaseFrame:self.view.bounds];
[self.view addSubview:sessionView];

你好我按照文档上这个代码写了一下,然后又按照你说的这个通知监听一下,然后监听方法里走了一次
AppWorkState_Logining 然后又走了一次AppWorkState_Logout 为啥会走登录成功后直接又走了注销呢 我没有 调用退出登录接口 我看控制太上报了一个这个错误
Thursday, December 26, 2019 at 10:09:33 AM China Standard Time 【Thread-68894】 +[QIMManager(XmppImManagerEvent) qim_privateCommonLog:] : qim_privateCommonLog :当前链接已失效或不存在,重新验证

这个链接指的是什么 我的域名和账号都是没问题的,谢谢

补充错误信息
2019-12-26 10:29:17.488690+0800 YDQIMCommon[1564:87900] Thursday, December 26, 2019 at 10:29:13 AM China Standard Time 【Thread-87900】 -[QIMManager(XmppImManagerEvent) messageLogEvent:]_block_invoke : <Method: messageLogEvent, MsgDirection_Receive :<=========== 接收了消息 ==========>
signalType: 5
pb_from: pc.yd.rajarcen.com
to: pc.yd.rajarcen.com
message: {length = 45, bytes = 0x08001a19 6e617574 682d6874 74702d72 ... 6e206661 696c6564 }
2019-12-26 10:29:17.507087+0800 YDQIMCommon[1564:87918] Thursday, December 26, 2019 at 10:29:13 AM China Standard Time 【Thread-87927】 +[QIMManager(XmppImManagerEvent) qim_privateCommonLog:] : qim_privateCommonLog :认证失败Error : code: 0
error: nauth-http-response-error
body {
value: login failed
}
2019-12-26 10:29:17.507701+0800 YDQIMCommon[1564:87918] Thursday, December 26, 2019 at 10:29:13 AM China Standard Time 【Thread-87927】 +[QIMManager(XmppImManagerEvent) qim_privateCommonLog:] : qim_privateCommonLog :认证失败 disconnectWithError : Error Domain=PBXMPPStreamErrorDomain Code=404 "Error Authen Faild" UserInfo={NSLocalizedDescription=Error Authen Faild}
2019-12-26 10:29:17.520954+0800 YDQIMCommon[1564:87918] Thursday, December 26, 2019 at 10:29:13 AM China Standard Time 【Thread-87922】 +[QIMManager(XmppImManagerEvent) qim_privateCommonLog:] : qim_privateCommonLog :didNotAuthenticate:signalType: 5
pb_from: pc.yd.rajarcen.com
to: pc.yd.rajarcen.com
message: {length = 45, bytes = 0x08001a19 6e617574 682d6874 74702d72 ... 6e206661 696c6564 }
2019-12-26 10:29:17.522096+0800 YDQIMCommon[1564:87918] Thursday, December 26, 2019 at 10:29:13 AM China Standard Time 【Thread-87673】 -[QIMManager(XmppImManagerEvent) loginFaild:]_block_invoke : LoginFaild: {
errCode = 0;
errMsg = "\U767b\U9646\U5ba2\U6237\U7aef\U5931\U8d25\U3002";
}
2019-12-26 10:29:17.523229+0800 YDQIMCommon[1564:87673] 退出
2019-12-26 10:29:17.523381+0800 YDQIMCommon[1564:87673] AppWorkState_Logout
2019-12-26 10:29:17.527777+0800 YDQIMCommon[1564:87900] Thursday, December 26, 2019 at 10:29:17 AM China Standard Time 【Thread-87927】 +[QIMManager(XmppImManagerEvent) qim_privateCommonLog:] : qim_privateCommonLog :Socket断开连接 <GCDAsyncSocket: 0x7fd38ad1ea60> (null)

同时问一下后台的返回错误码文档在哪里

AppWorkState_Logining 是登录中 AppWorkState_Logout 是没登录上 或者退出登录 没区分的那么细

可以看出来我上面发的登录失败的报错原因是啥吗,我的域名和用户名和密码都是对的啊 或者说在哪能看到登录失败的错误原因