Commit c7a8a1f0011719ffdef105b9368ec64973ffa898

Authored by iOS-Xiaowen
1 parent 278cc581

no message

CNLiveBLoginModule/Classes/Controller/CNLiveCompleteInfoController.m
@@ -13,7 +13,13 @@ @@ -13,7 +13,13 @@
13 #import "YYKit.h" 13 #import "YYKit.h"
14 14
15 #import "CNLiveNavigationBar.h" 15 #import "CNLiveNavigationBar.h"
  16 +#import "CNLiveCategory.h"
  17 +#import "CNUserInfoManager.h"
  18 +#import "CNLiveEnvironment.h"
  19 +#import "CNLiveManager.h"
  20 +
16 #import "CNLiveCompleteInfoView.h" 21 #import "CNLiveCompleteInfoView.h"
  22 +#import "CNLiveLoginRequest.h"
17 23
18 @interface CNLiveCompleteInfoController()<CNLiveCompleteInfoViewDelegate> 24 @interface CNLiveCompleteInfoController()<CNLiveCompleteInfoViewDelegate>
19 @property (nonatomic, strong) CNLiveCompleteInfoView *infoView; 25 @property (nonatomic, strong) CNLiveCompleteInfoView *infoView;
@@ -85,4 +91,30 @@ @@ -85,4 +91,30 @@
85 return _infoView; 91 return _infoView;
86 } 92 }
87 93
  94 +#pragma mark - 连接IM
  95 +- (void)connectionIM:(id)result{
  96 + NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];
  97 + NSString *faceUrl = [dic objectForKey:@"faceUrl"];
  98 + if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) {
  99 + //网家家默认头像地址
  100 + [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"];
  101 + }
  102 + [CNUserInfoManager saveUserinfoDic:dic];
  103 +
  104 + // 连接IM
  105 + __weak typeof(self) weakSelf = self;
  106 + [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{
  107 + __strong typeof(weakSelf) strongSelf = weakSelf;
  108 + if(!strongSelf) return;
  109 + // 进入tabbar
  110 + [CNLiveNotificationManager postNotificationName:CNLiveLoginSuccess object:nil];
  111 +
  112 + } failed:^(int code, NSString * _Nonnull msg) {
  113 + // 错误逻辑
  114 + __strong typeof(weakSelf) strongSelf = weakSelf;
  115 + if(!strongSelf) return;
  116 +
  117 + }];
  118 +}
  119 +
88 @end 120 @end
CNLiveBLoginModule/Classes/Controller/CNLiveLoginController.h
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 #import <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 10
11 NS_ASSUME_NONNULL_BEGIN 11 NS_ASSUME_NONNULL_BEGIN
  12 +UIKIT_EXTERN NSString *const kCNLiveLoginSuccess;
12 13
13 @interface CNLiveLoginController : UIViewController 14 @interface CNLiveLoginController : UIViewController
14 @property (nonatomic, assign) BOOL isShowClose; 15 @property (nonatomic, assign) BOOL isShowClose;
CNLiveBLoginModule/Classes/Controller/CNLiveLoginController.m
@@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
17 #import "CNUserInfoManager.h" 17 #import "CNUserInfoManager.h"
18 #import "CNLiveEnvironment.h" 18 #import "CNLiveEnvironment.h"
19 #import <CNLiveRequestBastKit/CNLiveNetworking.h> 19 #import <CNLiveRequestBastKit/CNLiveNetworking.h>
  20 +#import "CNLiveBusinessTools.h"
  21 +#import "CNLiveManager.h"
20 22
21 #import "CNLiveLoginView.h" 23 #import "CNLiveLoginView.h"
22 #import "CNLiveThreeLoginView.h" 24 #import "CNLiveThreeLoginView.h"
@@ -35,6 +37,7 @@ @@ -35,6 +37,7 @@
35 @end 37 @end
36 38
37 @implementation CNLiveLoginController 39 @implementation CNLiveLoginController
  40 +NSString *const kCNLiveLoginSuccess = @"CNLiveLoginSuccess";
38 41
39 #pragma mark - 生命周期 42 #pragma mark - 生命周期
40 - (void)viewWillAppear:(BOOL)animated{ 43 - (void)viewWillAppear:(BOOL)animated{
@@ -104,15 +107,7 @@ @@ -104,15 +107,7 @@
104 [self.navigationController pushViewController:vc animated:YES]; 107 [self.navigationController pushViewController:vc animated:YES];
105 108
106 }else{ 109 }else{
107 - // 老用户 -> home  
108 - [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{  
109 - // 进入tabbar  
110 -  
111 - } failed:^(int code, NSString * _Nonnull msg) {  
112 - // 错误逻辑  
113 -  
114 - }];  
115 - 110 + [self connectionIM:result];
116 } 111 }
117 112
118 } 113 }
@@ -151,9 +146,6 @@ @@ -151,9 +146,6 @@
151 model.faceUrl = userInfo.faceUrl; 146 model.faceUrl = userInfo.faceUrl;
152 model.thirdPartyId = userInfo.thirdPartyId; 147 model.thirdPartyId = userInfo.thirdPartyId;
153 148
154 -// model.countryName = strongSelf->_countryStr;  
155 -// model.countryCode = strongSelf->_codeStr;  
156 -// model.frmId = [CNTools getFrmId];  
157 switch (type) { 149 switch (type) {
158 case CNLiveSendAuthRespApple: 150 case CNLiveSendAuthRespApple:
159 { 151 {
@@ -176,11 +168,42 @@ @@ -176,11 +168,42 @@
176 } 168 }
177 break; 169 break;
178 } 170 }
179 - [strongSelf thirdPartyLoginWithType:type model:model]; 171 + if (type == CNLiveSendAuthRespApple) {
  172 + [strongSelf appleLogin:model];
  173 + }else {
  174 + [strongSelf thirdPartyLoginWithType:type model:model];
  175 + }
180 176
181 }]; 177 }];
182 178
183 } 179 }
  180 +- (void)appleLogin:(CNLiveThreeLoginModel *)model{
  181 + NSDictionary *params = @{@"thirdPartyPlat":model.thirdPartyPlat?model.thirdPartyPlat:@"",
  182 + @"thirdPartyId":model.thirdPartyId?model.thirdPartyId:@"",
  183 + @"frmId":model.frmId?model.frmId:@"",
  184 + @"clientPlat":@"i",
  185 + @"nickName":model.nickName?model.nickName:@"",
  186 + @"gender":model.gender?model.gender:@"",
  187 + @"location":model.location?model.location:@"",
  188 + @"faceUrl":model.faceUrl?model.faceUrl:@"",
  189 + @"uuid":[CNLiveBusinessTools getUidForStat:[NSDate date]],
  190 + @"appId":AppId};
  191 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  192 + [CNLiveNetworking setupShowDataResult:NO];
  193 +
  194 + [QMUITips showLoadingInView:self.view];
  195 + __weak typeof(self) weakSelf = self;
  196 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:@"https://api.cnlive.com/open/api2/user/loginIn3rdForWJJApple" Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  197 + __strong typeof(weakSelf) strongSelf = weakSelf;
  198 + if(!strongSelf) return;
  199 + [QMUITips hideAllToastInView:strongSelf.view animated:YES];
  200 + if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"0"]) {
  201 + [strongSelf connectionIM:responseObject];
  202 + }
  203 +
  204 + }];
  205 +
  206 +}
184 207
185 - (void)thirdPartyLoginWithType:(CNLiveSendAuthResp)type model:(CNLiveThreeLoginModel *)model{ 208 - (void)thirdPartyLoginWithType:(CNLiveSendAuthResp)type model:(CNLiveThreeLoginModel *)model{
186 [QMUITips showLoadingInView:self.view]; 209 [QMUITips showLoadingInView:self.view];
@@ -196,10 +219,6 @@ @@ -196,10 +219,6 @@
196 vc.block = ^(NSString * _Nonnull countryName, NSString * _Nonnull countryCode) { 219 vc.block = ^(NSString * _Nonnull countryName, NSString * _Nonnull countryCode) {
197 __strong typeof(weakSelf) strongSelf = weakSelf; 220 __strong typeof(weakSelf) strongSelf = weakSelf;
198 if(!strongSelf) return; 221 if(!strongSelf) return;
199 -// strongSelf->_mobileLocaLbl.text = countryName;  
200 -// strongSelf->_countryStr = countryName;  
201 -// strongSelf->_countryLbl.text = [NSString stringWithFormat:@"+%@",countryCode];  
202 -// strongSelf->_codeStr = countryCode;  
203 }; 222 };
204 vc.hidesBottomBarWhenPushed = YES; 223 vc.hidesBottomBarWhenPushed = YES;
205 [strongSelf presentViewController:vc animated:YES completion:nil]; 224 [strongSelf presentViewController:vc animated:YES completion:nil];
@@ -213,17 +232,7 @@ @@ -213,17 +232,7 @@
213 [userDefaults setObject:responseObject[@"data"][@"uid"] forKey:@"CNLiveUserSid"]; 232 [userDefaults setObject:responseObject[@"data"][@"uid"] forKey:@"CNLiveUserSid"];
214 [userDefaults synchronize]; 233 [userDefaults synchronize];
215 234
216 - // 连接IM  
217 - __weak typeof(strongSelf) weakSelf = strongSelf;  
218 - [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{  
219 - // 进入tabbar  
220 -  
221 - } failed:^(int code, NSString * _Nonnull msg) {  
222 - // 错误逻辑  
223 - __strong typeof(weakSelf) strongSelf = weakSelf;  
224 - if(!strongSelf) return;  
225 -  
226 - }]; 235 + [strongSelf connectionIM:responseObject];
227 236
228 } 237 }
229 else if ([responseObject isKindOfClass:[NSDictionary class]] ) { 238 else if ([responseObject isKindOfClass:[NSDictionary class]] ) {
@@ -271,4 +280,30 @@ @@ -271,4 +280,30 @@
271 280
272 } 281 }
273 282
  283 +#pragma mark - 连接IM
  284 +- (void)connectionIM:(id)result{
  285 + NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];
  286 + NSString *faceUrl = [dic objectForKey:@"faceUrl"];
  287 + if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) {
  288 + //网家家默认头像地址
  289 + [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"];
  290 + }
  291 + [CNUserInfoManager saveUserinfoDic:dic];
  292 +
  293 + // 连接IM
  294 + __weak typeof(self) weakSelf = self;
  295 + [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{
  296 + __strong typeof(weakSelf) strongSelf = weakSelf;
  297 + if(!strongSelf) return;
  298 + // 进入tabbar
  299 + [CNLiveNotificationManager postNotificationName:CNLiveLoginSuccess object:nil];
  300 +
  301 + } failed:^(int code, NSString * _Nonnull msg) {
  302 + // 错误逻辑
  303 + __strong typeof(weakSelf) strongSelf = weakSelf;
  304 + if(!strongSelf) return;
  305 +
  306 + }];
  307 +}
  308 +
274 @end 309 @end
CNLiveBLoginModule/Classes/Model/CNLiveClassifyOffsetManager.h deleted 100644 → 0
1 -//  
2 -// CNLiveClassifyOffsetManager.h  
3 -// CNLiveLoginModule  
4 -//  
5 -// Created by CNLive-zxw on 2019/3/27.  
6 -// Copyright © 2019年 cnlive. All rights reserved.  
7 -//  
8 -  
9 -#import <Foundation/Foundation.h>  
10 -  
11 -NS_ASSUME_NONNULL_BEGIN  
12 -  
13 -@interface CNLiveClassifyOffsetManager : NSObject  
14 -+ (instancetype)manager;  
15 -  
16 -  
17 -@end  
18 -  
19 -NS_ASSUME_NONNULL_END  
CNLiveBLoginModule/Classes/Model/CNLiveClassifyOffsetManager.m deleted 100644 → 0
1 -//  
2 -// CNLiveClassifyOffsetManager.m  
3 -// CNLiveLoginModule  
4 -//  
5 -// Created by CNLive-zxw on 2019/3/27.  
6 -// Copyright © 2019年 cnlive. All rights reserved.  
7 -//  
8 -  
9 -#import "CNLiveClassifyOffsetManager.h"  
10 -  
11 -@interface CNLiveClassifyOffsetManager ()  
12 -  
13 -@end  
14 -  
15 -@implementation CNLiveClassifyOffsetManager  
16 -#pragma mark - 单例  
17 -+ (instancetype)manager {  
18 - static CNLiveClassifyOffsetManager *_singleton = nil;  
19 - static dispatch_once_t onceToken;  
20 - dispatch_once(&onceToken, ^{  
21 - //不能再使用alloc方法  
22 - //因为已经重写了allocWithZone方法,所以这里要调用父类的分配空间的方法  
23 - _singleton = [[super allocWithZone:NULL] init];  
24 - });  
25 - return _singleton;  
26 -  
27 -}  
28 -  
29 -// 防止外部调用alloc 或者 new  
30 -+ (instancetype)allocWithZone:(struct _NSZone *)zone {  
31 - return [CNLiveClassifyOffsetManager manager];  
32 -  
33 -}  
34 -  
35 -// 防止外部调用copy  
36 -- (id)copyWithZone:(nullable NSZone *)zone {  
37 - return [CNLiveClassifyOffsetManager manager];  
38 -  
39 -}  
40 -  
41 -// 防止外部调用mutableCopy  
42 -- (id)mutableCopyWithZone:(nullable NSZone *)zone {  
43 - return [CNLiveClassifyOffsetManager manager];  
44 -  
45 -}  
46 -  
47 -@end  
CNLiveBLoginModule/Classes/Model/CNLiveLoginRequest.h
@@ -14,12 +14,8 @@ NS_ASSUME_NONNULL_BEGIN @@ -14,12 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
14 14
15 + (instancetype)manager; 15 + (instancetype)manager;
16 16
17 -- (void)getTIMLoginToken:(NSString *)identifier success:(void (^)(NSString * token))success failed:(void (^)(int code, NSString * msg))failed;  
18 -  
19 -  
20 - (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed; 17 - (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed;
21 18
22 -- (void)resumeLogin;  
23 19
24 @end 20 @end
25 21
CNLiveBLoginModule/Classes/Model/CNLiveLoginRequest.m
@@ -9,39 +9,22 @@ @@ -9,39 +9,22 @@
9 #import "CNLiveLoginRequest.h" 9 #import "CNLiveLoginRequest.h"
10 #import <UIKit/UIKit.h> 10 #import <UIKit/UIKit.h>
11 #import "QMUIKit.h" 11 #import "QMUIKit.h"
12 - 12 +#import <CNLiveBServices/CNLiveBServices.h>
13 #import "CNLiveEnvironment.h" 13 #import "CNLiveEnvironment.h"
14 -#import <CNLiveRequestBastKit/CNLiveNetworking.h>  
15 -#import "TIMAdapter.h"  
16 -#import "CommonLibrary.h"  
17 -  
18 -#import "NBSAppAgent.h"  
19 -#import "CNLiveBusinessTools.h"  
20 14
21 @interface CNLiveLoginRequest() 15 @interface CNLiveLoginRequest()
22 -@property (nonatomic, strong) IMALoginParam *loginParam;  
23 16
24 @end 17 @end
25 18
26 @implementation CNLiveLoginRequest 19 @implementation CNLiveLoginRequest
27 -static const NSInteger timeValue = 1.5;  
28 -#define XWKeyWindow [UIApplication sharedApplication].keyWindow 20 +//static const NSInteger timeValue = 1.5;
  21 +//#define XWKeyWindow [UIApplication sharedApplication].keyWindow
29 #pragma mark - 单例 22 #pragma mark - 单例
30 + (instancetype)manager { 23 + (instancetype)manager {
31 static CNLiveLoginRequest *_singleton = nil; 24 static CNLiveLoginRequest *_singleton = nil;
32 static dispatch_once_t onceToken; 25 static dispatch_once_t onceToken;
33 dispatch_once(&onceToken, ^{ 26 dispatch_once(&onceToken, ^{
34 _singleton = [[super allocWithZone:NULL] init]; 27 _singleton = [[super allocWithZone:NULL] init];
35 - BOOL isAutoLogin = [IMAPlatform isAutoLogin];  
36 -  
37 - if (isAutoLogin) {  
38 - _singleton.loginParam = [IMALoginParam loadFromLocal];  
39 -  
40 - } else {  
41 - _singleton.loginParam = [[IMALoginParam alloc] init];  
42 -  
43 - }  
44 - [IMAPlatform configWith:_singleton.loginParam.config];  
45 28
46 }); 29 });
47 return _singleton; 30 return _singleton;
@@ -63,134 +46,12 @@ static const NSInteger timeValue = 1.5; @@ -63,134 +46,12 @@ static const NSInteger timeValue = 1.5;
63 return [CNLiveLoginRequest manager]; 46 return [CNLiveLoginRequest manager];
64 } 47 }
65 48
66 -// 获取token  
67 -- (void)getTIMLoginToken:(NSString *)identifier success:(void (^)(NSString * token))success failed:(void (^)(int code, NSString * msg))failed{  
68 - NSDictionary *params = @{@"appId":AppId,  
69 - @"plat":@"i",  
70 - @"sdkAppId":SdkAppId,  
71 - @"identifier":identifier};  
72 - [CNLiveNetworking setupShowDataResult:NO];  
73 - [CNLiveNetworking setAllowRequestDefaultArgument:YES];  
74 - [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:TIM_GetTokenUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {  
75 - if (!error) {  
76 - if (responseObject && [responseObject isKindOfClass:[NSDictionary class]] && [[responseObject allKeys] containsObject:@"data"] && [[responseObject objectForKey:@"data"] isKindOfClass:[NSDictionary class]]) {  
77 - NSNumber *code = responseObject[@"errorCode"];  
78 - if (code && code.intValue == 0) {  
79 - if (success) {  
80 - success(responseObject[@"data"][@"token"]);  
81 - }  
82 - } else {  
83 - if (failed) {  
84 - failed(31012, @"获取token失败");  
85 - }  
86 - }  
87 - }  
88 - }else{  
89 - if (failed) failed(31012, @"获取token失败");  
90 - }  
91 - }];  
92 -  
93 -}  
94 -  
95 // 登录IM 49 // 登录IM
96 - (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed{ 50 - (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed{
97 - [QMUITips showLoading:@"正在连接服务器..." inView:XWKeyWindow];  
98 - // 1.获取token  
99 - [self getTIMLoginToken:uid success:^(NSString * _Nonnull token) {  
100 -  
101 - self.loginParam.identifier = uid;  
102 - self.loginParam.userSig = token;  
103 - self.loginParam.tokenTime = [[NSDate date] timeIntervalSince1970];  
104 -  
105 - // 2.登录im  
106 - [[IMAPlatform sharedInstance] login:self.loginParam succ:^{  
107 - [QMUITips hideAllToastInView:XWKeyWindow animated:YES];  
108 -  
109 - [self.loginParam saveToLocal];  
110 -  
111 - [[IMAPlatform sharedInstance].contactMgr asyncUpdateContact];  
112 - [[IMAPlatform sharedInstance].contactMgr saveGroupIdList:YES];  
113 - [[IMAPlatform sharedInstance] configHost:self.loginParam];  
114 - [IMAPlatform sharedInstance].didConnectSuccess = YES;  
115 -  
116 - // 听云  
117 - [NBSAppAgent setUserIdentifier:[CNLiveBusinessTools getSidIdfv]];  
118 -  
119 - [QMUITips showSucceed:@"登录成功" inView:XWKeyWindow hideAfterDelay:timeValue];  
120 - success?success():@"";  
121 -  
122 - // 3.im配置信息  
123 - [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{  
124 - NSLog(@"asyncSetAllowType Suc");  
125 - [self.loginParam saveToLocal];  
126 -  
127 - } fail:^(int code, NSString *msg) {  
128 - NSLog(@"asyncSetAllowType failed : %@", msg);  
129 -  
130 - }];  
131 -  
132 - } fail:^(int code, NSString *msg) {  
133 - NSLog(@"login failed : %@", msg);  
134 - [QMUITips hideAllToastInView:XWKeyWindow animated:YES];  
135 - if (code == 6208) {  
136 - // 离线被踢下线重新登录  
137 - [self resumeLogin];  
138 - }  
139 - else{  
140 - [QMUITips showError:msg inView:XWKeyWindow hideAfterDelay:timeValue];  
141 - failed?failed(code, msg):@"";  
142 - }  
143 - }];  
144 -  
145 - } failed:^(int code, NSString * _Nonnull msg) {  
146 - NSLog(@"token code:%d msg:%@", code, msg);  
147 - [QMUITips hideAllToastInView:XWKeyWindow animated:YES];  
148 - [QMUITips showError:msg inView:XWKeyWindow hideAfterDelay:timeValue];  
149 - failed?failed(code, msg):@"";  
150 -  
151 - }];  
152 - 51 + id<CNLiveBMessageServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveBMessageServiceProtocol)];
  52 + [service loginIM:uid appId:AppId sdkAppId:SdkAppId appKey:APPKey busiId:IM_Cer_BusiId];
  53 + success?success():@"";
153 } 54 }
154 55
155 -// 如果遇到离线被踢下线重新登录  
156 -- (void)resumeLogin {  
157 - __weak typeof(self)weakSelf = self;  
158 - [[IMAPlatform sharedInstance] login:self.loginParam succ:^{  
159 - [QMUITips hideAllToastInView:XWKeyWindow animated:YES];  
160 - [QMUITips showSucceed:@"登录成功" inView:XWKeyWindow hideAfterDelay:timeValue];  
161 - [self.loginParam saveToLocal];  
162 -  
163 - [[IMAPlatform sharedInstance] configHost:self.loginParam];  
164 - [IMAPlatform sharedInstance].didConnectSuccess = YES;  
165 -  
166 - [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{  
167 - NSLog(@"asyncSetAllowType Suc");  
168 - [self.loginParam saveToLocal];  
169 -  
170 - } fail:^(int code, NSString *msg) {  
171 - NSLog(@"asyncSetAllowType failed : %@", msg);  
172 - }];  
173 -  
174 - } fail:^(int code, NSString *msg) {  
175 - NSLog(@"tokenCode login failed : %@", msg);  
176 - if (code == 6028) {  
177 - dispatch_async(dispatch_get_main_queue(), ^{  
178 - QMUIAlertAction *action = [QMUIAlertAction actionWithTitle:@"重试" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {  
179 - [weakSelf resumeLogin];  
180 - }];  
181 - QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"连接服务器失败,请点击重试" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet];  
182 - [alertController addAction:action];  
183 -  
184 - NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];  
185 -  
186 - titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];  
187 -  
188 - action.buttonAttributes = titleAttributs;  
189 - [alertController showWithAnimated:YES];  
190 -  
191 - });  
192 - }  
193 - }];  
194 -}  
195 56
196 @end 57 @end
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveBindingTelController.m
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 #import "CNLiveNavigationBar.h" 17 #import "CNLiveNavigationBar.h"
18 #import "CNLiveBindingTelView.h" 18 #import "CNLiveBindingTelView.h"
19 19
20 -@interface CNLiveBindingTelController()<CNLiveBindingTelViewDelegate> 20 +@interface CNLiveBindingTelController()
21 @property (nonatomic, assign) CNLiveThreeLoginType type; 21 @property (nonatomic, assign) CNLiveThreeLoginType type;
22 @property (nonatomic, strong) CNLiveNavigationBar *navigationBar; 22 @property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
23 23
@@ -59,11 +59,6 @@ @@ -59,11 +59,6 @@
59 [self.view endEditing:YES]; 59 [self.view endEditing:YES];
60 } 60 }
61 61
62 -#pragma mark - CNLiveBindingTelViewDelegate  
63 -- (void)bindingSuccess:(CNLiveBindingTelView *)view type:(CNLiveThreeLoginType)type{  
64 -  
65 -}  
66 -  
67 /* 62 /*
68 #pragma mark - Navigation 63 #pragma mark - Navigation
69 64
@@ -92,7 +87,6 @@ @@ -92,7 +87,6 @@
92 - (CNLiveBindingTelView *)bindingTelView { 87 - (CNLiveBindingTelView *)bindingTelView {
93 if (!_bindingTelView) { 88 if (!_bindingTelView) {
94 _bindingTelView = [[CNLiveBindingTelView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/8.0, NavigationContentTop, self.view.frame.size.width*3/4.0, 400) type:self.type]; 89 _bindingTelView = [[CNLiveBindingTelView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/8.0, NavigationContentTop, self.view.frame.size.width*3/4.0, 400) type:self.type];
95 - _bindingTelView.delegate = self;  
96 } 90 }
97 return _bindingTelView; 91 return _bindingTelView;
98 } 92 }
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveBindingTelView.h
@@ -11,14 +11,7 @@ @@ -11,14 +11,7 @@
11 11
12 NS_ASSUME_NONNULL_BEGIN 12 NS_ASSUME_NONNULL_BEGIN
13 13
14 -@class CNLiveBindingTelView;  
15 -@protocol CNLiveBindingTelViewDelegate <NSObject>  
16 -- (void)bindingSuccess:(CNLiveBindingTelView *)view type:(CNLiveThreeLoginType)type;  
17 -  
18 -@end  
19 -  
20 @interface CNLiveBindingTelView : UIView 14 @interface CNLiveBindingTelView : UIView
21 -@property (nonatomic, weak) id<CNLiveBindingTelViewDelegate> delegate;  
22 - (instancetype)initWithFrame:(CGRect)frame type:(CNLiveThreeLoginType)type; 15 - (instancetype)initWithFrame:(CGRect)frame type:(CNLiveThreeLoginType)type;
23 16
24 @end 17 @end
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveBindingTelView.m
@@ -16,10 +16,12 @@ @@ -16,10 +16,12 @@
16 #import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h> 16 #import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h>
17 #import <CNLiveUserSystemSDK/CNLiveUserSystemTypeDef.h> 17 #import <CNLiveUserSystemSDK/CNLiveUserSystemTypeDef.h>
18 #import "CNUserInfoManager.h" 18 #import "CNUserInfoManager.h"
  19 +#import "CNLiveManager.h"
19 20
20 #import "CNLiveLoginCountryView.h" 21 #import "CNLiveLoginCountryView.h"
21 #import "CNLiveLoginTextField.h" 22 #import "CNLiveLoginTextField.h"
22 #import "CNLiveCountDownButton.h" 23 #import "CNLiveCountDownButton.h"
  24 +#import "CNLiveLoginRequest.h"
23 25
24 @interface CNLiveBindingTelView()<UITextFieldDelegate,CNLiveCountDownButtonDataSource, CNLiveCountDownButtonDelegate> 26 @interface CNLiveBindingTelView()<UITextFieldDelegate,CNLiveCountDownButtonDataSource, CNLiveCountDownButtonDelegate>
25 { 27 {
@@ -353,9 +355,20 @@ static const NSInteger timeValue = 1.5; @@ -353,9 +355,20 @@ static const NSInteger timeValue = 1.5;
353 [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"]; 355 [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"];
354 } 356 }
355 [CNUserInfoManager saveUserinfoDic:dic]; 357 [CNUserInfoManager saveUserinfoDic:dic];
356 - if (self.delegate && [self.delegate respondsToSelector:@selector(bindingSuccess:type:)]) {  
357 - [self.delegate bindingSuccess:self type:self.type];  
358 - } 358 + // 连接IM
  359 + __weak typeof(self) weakSelf = self;
  360 + [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{
  361 + __strong typeof(weakSelf) strongSelf = weakSelf;
  362 + if(!strongSelf) return;
  363 + // 进入tabbar
  364 + [CNLiveNotificationManager postNotificationName:CNLiveLoginSuccess object:nil];
  365 +
  366 + } failed:^(int code, NSString * _Nonnull msg) {
  367 + // 错误逻辑
  368 + __strong typeof(weakSelf) strongSelf = weakSelf;
  369 + if(!strongSelf) return;
  370 +
  371 + }];
359 } 372 }
360 373
361 @end 374 @end
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveThreeLoginView.m
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 #import "CNLiveCategory.h" 11 #import "CNLiveCategory.h"
12 #import "CNLiveShareImageManager.h" 12 #import "CNLiveShareImageManager.h"
13 #import "WXApi.h" 13 #import "WXApi.h"
  14 +#import <AuthenticationServices/AuthenticationServices.h>
14 15
15 @interface CNLiveThreeLoginView() 16 @interface CNLiveThreeLoginView()
16 17
@@ -58,20 +59,30 @@ static NSInteger const rowHeight = 60; @@ -58,20 +59,30 @@ static NSInteger const rowHeight = 60;
58 CGFloat btnWidth = width/number*1.0; 59 CGFloat btnWidth = width/number*1.0;
59 60
60 for(int i = 0; i < pics.count; i++){ 61 for(int i = 0; i < pics.count; i++){
61 - UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];  
62 - btn.tag = 10000+i;  
63 - btn.frame = CGRectMake(btnWidth*i, name.bottom, btnWidth, rowHeight);  
64 - if (@available(iOS 13, *)) {  
65 - if (i == pics.count-1) {  
66 - btn.frame = CGRectMake(btnWidth*i, name.bottom, 2*btnWidth, rowHeight);  
67 - } 62 + // 苹果登录在最后一个
  63 + if (i == pics.count-1) {
  64 + if (@available(iOS 13, *)) {
  65 + ASAuthorizationAppleIDButton *btn = [ASAuthorizationAppleIDButton buttonWithType:ASAuthorizationAppleIDButtonTypeDefault style:ASAuthorizationAppleIDButtonStyleWhite];
  66 + btn.tag = 10000+i;
  67 + btn.layer.masksToBounds = YES;
  68 + btn.layer.cornerRadius = 18.0;
  69 + btn.layer.borderWidth = 1.0;
  70 + btn.layer.borderColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0].CGColor;
  71 + btn.frame = CGRectMake(btnWidth*i, name.bottom+12, 2*btnWidth, 36);
  72 + [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  73 + [self addSubview:btn];
  74 + }
  75 +
  76 + }else {
  77 + UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  78 + btn.tag = 10000+i;
  79 + btn.frame = CGRectMake(btnWidth*i, name.bottom, btnWidth, rowHeight);
  80 + UIImage *image = [self getImageWithImageName:pics[i] bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  81 + [btn setImage:image forState:UIControlStateNormal];
  82 + btn.adjustsImageWhenHighlighted = NO;
  83 + [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  84 + [self addSubview:btn];
68 } 85 }
69 - UIImage *image = [self getImageWithImageName:pics[i] bundleName:@"CNLiveBLoginModule" targetClass:[self class]];  
70 - [btn setImage:image forState:UIControlStateNormal];  
71 - btn.adjustsImageWhenHighlighted = NO;  
72 - [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside];  
73 - [self addSubview:btn];  
74 -  
75 } 86 }
76 87
77 } 88 }
CNLiveBLoginModule/Classes/View/CNLiveCompleteInfoView.m
@@ -260,8 +260,7 @@ static const NSInteger timeValue = 1.5; @@ -260,8 +260,7 @@ static const NSInteger timeValue = 1.5;
260 [QMUITips hideAllToastInView:strongSelf.superview animated:YES]; 260 [QMUITips hideAllToastInView:strongSelf.superview animated:YES];
261 261
262 if (!strongSelf->_image) { 262 if (!strongSelf->_image) {
263 - [strongSelf connectionIM:result];  
264 - 263 + [strongSelf callback:result];
265 }else{ 264 }else{
266 [strongSelf modifyIcon]; 265 [strongSelf modifyIcon];
267 } 266 }
@@ -294,7 +293,7 @@ static const NSInteger timeValue = 1.5; @@ -294,7 +293,7 @@ static const NSInteger timeValue = 1.5;
294 faceUrl = deFaceUrl; 293 faceUrl = deFaceUrl;
295 } 294 }
296 CNUserShareModel.faceUrl = faceUrl; 295 CNUserShareModel.faceUrl = faceUrl;
297 - [strongSelf connectionIM:result]; 296 + [strongSelf callback:result];
298 297
299 } failure:^(NSDictionary *errorDic) { 298 } failure:^(NSDictionary *errorDic) {
300 __strong typeof(weakSelf) strongSelf = weakSelf; 299 __strong typeof(weakSelf) strongSelf = weakSelf;
@@ -306,32 +305,12 @@ static const NSInteger timeValue = 1.5; @@ -306,32 +305,12 @@ static const NSInteger timeValue = 1.5;
306 305
307 } 306 }
308 307
309 -// 连接IM  
310 -- (void)connectionIM:(id)result{  
311 - NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];  
312 - NSString *faceUrl = [dic objectForKey:@"faceUrl"];  
313 - if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) {  
314 - //网家家默认头像地址  
315 - [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"]; 308 +// 回调
  309 +- (void)callback:(id)result{
  310 + // 进入tabbar
  311 + if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:result:)]) {
  312 + [self.delegate loginSuccess:self result:result];
316 } 313 }
317 - [CNUserInfoManager saveUserinfoDic:dic];  
318 -  
319 - __weak typeof(self) weakSelf = self;  
320 - [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{  
321 - __strong typeof(weakSelf) strongSelf = weakSelf;  
322 - if(!strongSelf) return;  
323 - // 进入tabbar  
324 - if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(loginSuccess:result:)]) {  
325 - [strongSelf.delegate loginSuccess:strongSelf result:result];  
326 - }  
327 -  
328 - } failed:^(int code, NSString * _Nonnull msg) {  
329 - __strong typeof(weakSelf) strongSelf = weakSelf;  
330 - if(!strongSelf) return;  
331 - // 错误逻辑  
332 - [QMUITips showError:msg inView:strongSelf.superview hideAfterDelay:timeValue];  
333 -  
334 - }];  
335 314
336 } 315 }
337 316
CNLiveBLoginModule/Classes/View/CNLiveLoginView.m
@@ -327,7 +327,7 @@ static const NSInteger timeValue = 1.5; @@ -327,7 +327,7 @@ static const NSInteger timeValue = 1.5;
327 if(!strongSelf) return; 327 if(!strongSelf) return;
328 [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; 328 [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
329 // 连接IM 329 // 连接IM
330 - [strongSelf connectionIM:result]; 330 + [strongSelf callback:result];
331 331
332 } failure:^(NSDictionary *errorDic) { 332 } failure:^(NSDictionary *errorDic) {
333 btn.userInteractionEnabled = YES; 333 btn.userInteractionEnabled = YES;
@@ -338,18 +338,11 @@ static const NSInteger timeValue = 1.5; @@ -338,18 +338,11 @@ static const NSInteger timeValue = 1.5;
338 }]; 338 }];
339 } 339 }
340 340
341 -#pragma mark - 连接IM  
342 -- (void)connectionIM:(id)result{ 341 +#pragma mark - 回调
  342 +- (void)callback:(id)result{
343 NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]]; 343 NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];
344 - NSString *faceUrl = [dic objectForKey:@"faceUrl"];  
345 - if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) {  
346 - //网家家默认头像地址  
347 - [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"];  
348 - }  
349 - [CNUserInfoManager saveUserinfoDic:dic];  
350 -  
351 - // YES 新用户 NO 老用户  
352 BOOL isNewUser = [dic[@"isNewUser"] intValue] != 0; 344 BOOL isNewUser = [dic[@"isNewUser"] intValue] != 0;
  345 + // YES 新用户 NO 老用户
353 if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:isNewUser:result:)]) { 346 if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:isNewUser:result:)]) {
354 [self.delegate loginSuccess:self isNewUser:isNewUser result:result]; 347 [self.delegate loginSuccess:self isNewUser:isNewUser result:result];
355 } 348 }
Example/CNLiveBLoginModule.xcodeproj/project.pbxproj
@@ -585,7 +585,7 @@ @@ -585,7 +585,7 @@
585 GCC_PREFIX_HEADER = "CNLiveBLoginModule/CNLiveBLoginModule-Prefix.pch"; 585 GCC_PREFIX_HEADER = "CNLiveBLoginModule/CNLiveBLoginModule-Prefix.pch";
586 INFOPLIST_FILE = "CNLiveBLoginModule/CNLiveBLoginModule-Info.plist"; 586 INFOPLIST_FILE = "CNLiveBLoginModule/CNLiveBLoginModule-Info.plist";
587 MODULE_NAME = ExampleApp; 587 MODULE_NAME = ExampleApp;
588 - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd; 588 + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetPlusBusiness;
589 PRODUCT_NAME = "$(TARGET_NAME)"; 589 PRODUCT_NAME = "$(TARGET_NAME)";
590 SWIFT_VERSION = 4.0; 590 SWIFT_VERSION = 4.0;
591 TARGETED_DEVICE_FAMILY = 1; 591 TARGETED_DEVICE_FAMILY = 1;
@@ -603,7 +603,7 @@ @@ -603,7 +603,7 @@
603 GCC_PREFIX_HEADER = "CNLiveBLoginModule/CNLiveBLoginModule-Prefix.pch"; 603 GCC_PREFIX_HEADER = "CNLiveBLoginModule/CNLiveBLoginModule-Prefix.pch";
604 INFOPLIST_FILE = "CNLiveBLoginModule/CNLiveBLoginModule-Info.plist"; 604 INFOPLIST_FILE = "CNLiveBLoginModule/CNLiveBLoginModule-Info.plist";
605 MODULE_NAME = ExampleApp; 605 MODULE_NAME = ExampleApp;
606 - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd; 606 + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetPlusBusiness;
607 PRODUCT_NAME = "$(TARGET_NAME)"; 607 PRODUCT_NAME = "$(TARGET_NAME)";
608 SWIFT_VERSION = 4.0; 608 SWIFT_VERSION = 4.0;
609 TARGETED_DEVICE_FAMILY = 1; 609 TARGETED_DEVICE_FAMILY = 1;