| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- //
- // IMAPlatform+Login.m
- // TIMChat
- //
- // Created by AlexiChen on 16/2/26.
- // Copyright © 2016年 AlexiChen. All rights reserved.
- //
- #import "IMAPlatform+Login.h"
- #import "BogoNetworkKit.h"
- #import <ImSDK_Plus/ImSDK_Plus.h>
- @implementation IMAPlatform (Login)
- //互踢下线错误码
- #define kEachKickErrorCode 6208
- - (void)loginTIMSDK:(TIMLoginParam *)param succ:(TIMLoginSucc)succ fail:(TIMFail)fail
- {
- if (!param)
- {
- return;
- }
-
- __weak IMAPlatform *ws = self;
-
- [[V2TIMManager sharedInstance] login:param.identifier userSig:param.userSig succ:^{
- DebugLog(@"登录成功:%@ tinyid:%llu sig:%@", param.identifier, [[IMSdkInt sharedInstance] getTinyId], param.userSig);
- [IMAPlatform setAutoLogin:YES];
- [BogoNetwork shareInstance].uid = param.identifier;
- if (succ)
- {
- succ();
- }
- } fail:^(int code, NSString *desc) {
- DebugLog(@"TIMLogin Failed: code=%d err=%@", code, desc);
- if (code == kEachKickErrorCode)
- {
- // 互踢重联
- // 重新再登录一次
- [ws offlineKicked:param succ:succ fail:fail];
- }
- else
- {
- if (fail)
- {
- fail(code, desc);
- }
- }
- }];
-
-
- /*[[TIMManager sharedInstance] login:param succ:^{
-
- DebugLog(@"登录成功:%@ tinyid:%llu sig:%@", param.identifier, [[IMSdkInt sharedInstance] getTinyId], param.userSig);
- [IMAPlatform setAutoLogin:YES];
- [BogoNetwork shareInstance].uid = param.identifier;
- if (succ)
- {
- succ();
- }
- } fail:^(int code, NSString *msg) {
-
- DebugLog(@"TIMLogin Failed: code=%d err=%@", code, msg);
- if (code == kEachKickErrorCode)
- {
- // 互踢重联
- // 重新再登录一次
- [ws offlineKicked:param succ:succ fail:fail];
- }
- else
- {
- if (fail)
- {
- fail(code, msg);
- }
- }
- }];*/
- }
- //离线被踢
- //用户离线时,在其它终端登录过,再次在本设备登录时,会提示被踢下线,需要重新登录
- - (void)offlineKicked:(TIMLoginParam *)param succ:(TIMLoginSucc)succ fail:(TIMFail)fail
- {
- // UIAlertView *alert = [UIAlertView bk_showAlertViewWithTitle:@"下线通知" message:@"您的帐号于另一台手机上登录。" cancelButtonTitle:@"退出" otherButtonTitles:@[@"重新登录"] handler:^(UIAlertView *alertView, NSInteger buttonIndex) {
- // if (buttonIndex == 0)
- // {
- // // 退出
- // [self logout:^{
- // [[AppDelegate sharedAppDelegate] enterLoginUI];
- // } fail:^(int code, NSString *msg) {
- // [[AppDelegate sharedAppDelegate] enterLoginUI];
- // }];
- // }
- // else
- // {
- [self offlineLogin];
- // 重新登录
- [self loginTIMSDK:param succ:succ fail:fail];
- // }
- // }];
- // [alert show];
- }
- - (void)configOnEnterMainUIWith:(TIMLoginParam *)param
- {
- // 配置, 获取个人名片
- [self configHost:param];
-
- // TODO:用户可结合自身逻辑,看是否处理退历器直播间消息
- [self asyncExitHistoryAVChatRoom];
- }
- @end
|