Commit 2bf37f4f103fdb282897760b941225512fbf9477

Authored by zhangxiaowen
1 parent cb0afa65

no message

CNLiveLoginModule.podspec
@@ -106,6 +106,11 @@ TODO: 网家家-登录模块. @@ -106,6 +106,11 @@ TODO: 网家家-登录模块.
106 # 相机 106 # 相机
107 s.dependency 'CNLiveAVCamera' 107 s.dependency 'CNLiveAVCamera'
108 108
  109 + #IM
  110 + s.dependency 'CNLiveIMBaseSDK'
  111 +
  112 + s.dependency 'tingyunApp', '~>2.14.0'
  113 +
109 s.static_framework = true 114 s.static_framework = true
110 115
111 end 116 end
CNLiveLoginModule/Classes/Controller/CNLiveCompleteInfoController.m
@@ -34,7 +34,6 @@ @@ -34,7 +34,6 @@
34 self.automaticallyAdjustsScrollViewInsets = NO; 34 self.automaticallyAdjustsScrollViewInsets = NO;
35 self.view.backgroundColor = [UIColor whiteColor]; 35 self.view.backgroundColor = [UIColor whiteColor];
36 [self createUI]; 36 [self createUI];
37 -  
38 } 37 }
39 38
40 - (void)createUI{ 39 - (void)createUI{
CNLiveLoginModule/Classes/Model/CNLiveLoginRequestModel.h 0 → 100644
  1 +//
  2 +// CNLiveLoginRequestModel.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveLoginRequestModel : NSObject
  14 ++ (void)getTIMLoginToken:(NSString *)identifier successBlock:(void (^)(NSString *))successBlock failedBlock:(void (^)(int, NSString *))errorBlock;
  15 +
  16 +@end
  17 +
  18 +NS_ASSUME_NONNULL_END
CNLiveLoginModule/Classes/Model/CNLiveLoginRequestModel.m 0 → 100644
  1 +//
  2 +// CNLiveLoginRequestModel.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveLoginRequestModel.h"
  10 +#import "CNUserInfoManager.h"
  11 +#import "CNLiveEnvironment.h"
  12 +#import <CNLiveRequestBastKit/CNLiveNetworking.h>
  13 +
  14 +@implementation CNLiveLoginRequestModel
  15 +
  16 +//获取token
  17 ++ (void)getTIMLoginToken:(NSString *)identifier successBlock:(void (^)(NSString *))successBlock failedBlock:(void (^)(int, NSString *))errorBlock {
  18 +
  19 + NSDictionary *params = @{@"appId":AppId,
  20 + @"plat":@"i",
  21 + @"sdkAppId":SdkAppId,
  22 + @"identifier":identifier};
  23 +
  24 + [CNLiveNetworking setupShowDataResult:NO];
  25 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  26 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:TIM_GetTokenUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  27 + if (!error) {
  28 + if (responseObject && ![responseObject isKindOfClass:[NSNull class]] && [responseObject isKindOfClass:[NSDictionary class]] && [[responseObject allKeys] containsObject:@"data"] && [[responseObject objectForKey:@"data"] isKindOfClass:[NSDictionary class]]) {
  29 + NSNumber *code = responseObject[@"errorCode"];
  30 + if (code && code.intValue == 0) {
  31 +// self.userSig = responseObject[@"data"][@"token"];
  32 + if (successBlock) {
  33 + successBlock(responseObject[@"data"][@"token"]);
  34 + }
  35 + } else {
  36 + if (errorBlock) {
  37 + errorBlock(31012, @"获取token失败");
  38 + }
  39 + }
  40 +
  41 + }
  42 +
  43 + }else{
  44 + if (errorBlock) errorBlock(31012,@"Token acquisition failure");
  45 + }
  46 + }];
  47 +
  48 +}
  49 +@end
CNLiveLoginModule/Classes/View/CNLiveCompleteInfoView.m
@@ -11,13 +11,22 @@ @@ -11,13 +11,22 @@
11 #import "YYKit.h" 11 #import "YYKit.h"
12 #import "QMUIKit.h" 12 #import "QMUIKit.h"
13 13
  14 +#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h>
  15 +#import <CNLiveUserSystemSDK/CNLiveUserSystemTypeDef.h>
14 #import "CNUserInfoManager.h" 16 #import "CNUserInfoManager.h"
15 - 17 +#import "CNLiveEnvironment.h"
  18 +#import "CNLiveManager.h"
16 #import <AVFoundation/AVCaptureDevice.h> 19 #import <AVFoundation/AVCaptureDevice.h>
17 #import <AVFoundation/AVMediaFormat.h> 20 #import <AVFoundation/AVMediaFormat.h>
18 #import "XFCameraController.h" 21 #import "XFCameraController.h"
19 #import "TZImagePickerController.h" 22 #import "TZImagePickerController.h"
20 23
  24 +#import "TIMAdapter.h"
  25 +#import "CommonLibrary.h"
  26 +#import "NBSAppAgent.h"
  27 +#import "CNLiveBusinessTools.h"
  28 +#import "CNLiveLoginRequestModel.h"
  29 +
21 @interface CNLiveCompleteInfoView()<UITextFieldDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,TZImagePickerControllerDelegate,QMUIAlertControllerDelegate>{ 30 @interface CNLiveCompleteInfoView()<UITextFieldDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,TZImagePickerControllerDelegate,QMUIAlertControllerDelegate>{
22 UIImage *_image; 31 UIImage *_image;
23 } 32 }
@@ -25,6 +34,7 @@ @@ -25,6 +34,7 @@
25 @property (nonatomic, weak) UIButton *head; 34 @property (nonatomic, weak) UIButton *head;
26 @property (nonatomic, weak) CNLiveLoginTextField *nickname; 35 @property (nonatomic, weak) CNLiveLoginTextField *nickname;
27 @property (nonatomic, weak) UIButton *next; 36 @property (nonatomic, weak) UIButton *next;
  37 +@property (nonatomic, strong) IMALoginParam *loginParam;
28 38
29 @end 39 @end
30 @implementation CNLiveCompleteInfoView 40 @implementation CNLiveCompleteInfoView
@@ -37,11 +47,13 @@ static const NSInteger timeValue = 1.5; @@ -37,11 +47,13 @@ static const NSInteger timeValue = 1.5;
37 if (self) { 47 if (self) {
38 self.userInteractionEnabled = YES; 48 self.userInteractionEnabled = YES;
39 [self createSubviews:frame]; 49 [self createSubviews:frame];
  50 + _loginParam = [[IMALoginParam alloc] init];
40 _image = nil; 51 _image = nil;
41 } 52 }
42 return self; 53 return self;
43 54
44 } 55 }
  56 +
45 - (void)createSubviews:(CGRect)frame{ 57 - (void)createSubviews:(CGRect)frame{
46 UIButton *head = [UIButton buttonWithType:UIButtonTypeCustom]; 58 UIButton *head = [UIButton buttonWithType:UIButtonTypeCustom];
47 head.frame = CGRectMake((frame.size.width-80)/2.0, 0, 80, 80); 59 head.frame = CGRectMake((frame.size.width-80)/2.0, 0, 80, 80);
@@ -85,30 +97,28 @@ static const NSInteger timeValue = 1.5; @@ -85,30 +97,28 @@ static const NSInteger timeValue = 1.5;
85 self.next = next; 97 self.next = next;
86 98
87 } 99 }
  100 +
88 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { 101 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
89 [self endEditing:YES]; 102 [self endEditing:YES];
90 103
91 } 104 }
  105 +
92 #pragma mark - UITextFieldDelegate 106 #pragma mark - UITextFieldDelegate
93 - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ 107 - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
94 if ([textField isEqual:_nickname]) { 108 if ([textField isEqual:_nickname]) {
95 return YES; 109 return YES;
96 -  
97 } 110 }
98 else { 111 else {
99 return YES; 112 return YES;
100 -  
101 } 113 }
102 } 114 }
103 115
104 - (void)textFieldDidChange:(UITextField *)textField { 116 - (void)textFieldDidChange:(UITextField *)textField {
105 if (![_nickname.text isEqualToString:@""]) { 117 if (![_nickname.text isEqualToString:@""]) {
106 _next.enabled = YES; 118 _next.enabled = YES;
107 -  
108 } 119 }
109 else { 120 else {
110 _next.enabled = NO; 121 _next.enabled = NO;
111 -  
112 } 122 }
113 123
114 } 124 }
@@ -148,7 +158,7 @@ static const NSInteger timeValue = 1.5; @@ -148,7 +158,7 @@ static const NSInteger timeValue = 1.5;
148 __strong typeof(weakSelf) strongSelf = weakSelf; 158 __strong typeof(weakSelf) strongSelf = weakSelf;
149 if(!strongSelf) return ; 159 if(!strongSelf) return ;
150 __strong typeof(strongSelf) weakSelf = strongSelf; 160 __strong typeof(strongSelf) weakSelf = strongSelf;
151 - [strongSelf getAVAuthorizationStatus:^{ 161 + [CNLiveAuthorizationManager getAVAuthorizationStatus:^{
152 __strong typeof(weakSelf) strongSelf = weakSelf; 162 __strong typeof(weakSelf) strongSelf = weakSelf;
153 if(!strongSelf) return ; 163 if(!strongSelf) return ;
154 XFCameraController *cameraController = [[XFCameraController alloc] init]; 164 XFCameraController *cameraController = [[XFCameraController alloc] init];
@@ -160,7 +170,8 @@ static const NSInteger timeValue = 1.5; @@ -160,7 +170,8 @@ static const NSInteger timeValue = 1.5;
160 __strong typeof(weakSelf) strongSelf = weakSelf; 170 __strong typeof(weakSelf) strongSelf = weakSelf;
161 if(!strongSelf) return ; 171 if(!strongSelf) return ;
162 strongSelf->_image = image; 172 strongSelf->_image = image;
163 - [strongSelf.head setImage:image forState:UIControlStateNormal]; 173 + [strongSelf modifyIcon];
  174 +// [strongSelf.head setImage:image forState:UIControlStateNormal];
164 175
165 dispatch_async(dispatch_get_main_queue(), ^{ 176 dispatch_async(dispatch_get_main_queue(), ^{
166 [weakCameraController dismissViewControllerAnimated:YES completion:nil]; 177 [weakCameraController dismissViewControllerAnimated:YES completion:nil];
@@ -175,7 +186,7 @@ static const NSInteger timeValue = 1.5; @@ -175,7 +186,7 @@ static const NSInteger timeValue = 1.5;
175 __strong typeof(weakSelf) strongSelf = weakSelf; 186 __strong typeof(weakSelf) strongSelf = weakSelf;
176 if(!strongSelf) return ; 187 if(!strongSelf) return ;
177 __strong typeof(strongSelf) weakSelf = strongSelf; 188 __strong typeof(strongSelf) weakSelf = strongSelf;
178 - [strongSelf getPHAuthorizationStatus:^{ 189 + [CNLiveAuthorizationManager getPHAuthorizationStatus:^{
179 __strong typeof(weakSelf) strongSelf = weakSelf; 190 __strong typeof(weakSelf) strongSelf = weakSelf;
180 if(!strongSelf) return ; 191 if(!strongSelf) return ;
181 TZImagePickerController *picker = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:strongSelf]; 192 TZImagePickerController *picker = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:strongSelf];
@@ -187,7 +198,8 @@ static const NSInteger timeValue = 1.5; @@ -187,7 +198,8 @@ static const NSInteger timeValue = 1.5;
187 __strong typeof(weakSelf) strongSelf = weakSelf; 198 __strong typeof(weakSelf) strongSelf = weakSelf;
188 if(!strongSelf) return ; 199 if(!strongSelf) return ;
189 strongSelf->_image = [photos firstObject]; 200 strongSelf->_image = [photos firstObject];
190 - [strongSelf.head setImage:[photos firstObject] forState:UIControlStateNormal]; 201 + [strongSelf modifyIcon];
  202 +// [strongSelf.head setImage:[photos firstObject] forState:UIControlStateNormal];
191 }]; 203 }];
192 [(UIViewController *)strongSelf.delegate presentViewController:picker animated:YES completion:nil]; 204 [(UIViewController *)strongSelf.delegate presentViewController:picker animated:YES completion:nil];
193 }]; 205 }];
@@ -219,38 +231,111 @@ static const NSInteger timeValue = 1.5; @@ -219,38 +231,111 @@ static const NSInteger timeValue = 1.5;
219 [alertController showWithAnimated:YES]; 231 [alertController showWithAnimated:YES];
220 232
221 } 233 }
  234 +
222 - (void)didHideAlertController:(QMUIAlertController *)alertController{ 235 - (void)didHideAlertController:(QMUIAlertController *)alertController{
223 self.head.userInteractionEnabled = YES; 236 self.head.userInteractionEnabled = YES;
224 -  
225 } 237 }
  238 +
  239 +#pragma mark - 响应方法
226 - (void)nextDidClicked:(UIButton *)btn{ 240 - (void)nextDidClicked:(UIButton *)btn{
227 [_nickname resignFirstResponder]; 241 [_nickname resignFirstResponder];
228 if ([_nickname.text isEqualToString:@""]) { 242 if ([_nickname.text isEqualToString:@""]) {
229 [QMUITips showError:@"请输入昵称" inView:self.superview hideAfterDelay:timeValue]; 243 [QMUITips showError:@"请输入昵称" inView:self.superview hideAfterDelay:timeValue];
230 return; 244 return;
231 } 245 }
232 - btn.userInteractionEnabled = NO; 246 + self.next.userInteractionEnabled = NO;
233 [self.superview endEditing:YES]; 247 [self.superview endEditing:YES];
234 - /**  
235 - * 修改昵称和头像  
236 - **/ 248 + [self modifyNickName];
  249 +}
  250 +
  251 +// 修改头像
  252 +- (void)modifyIcon {
  253 + [QMUITips showLoading:@"修改中" inView:self.superview];
  254 + [CNLiveUserSystemCenter uploadIconWithUid:CNUserShareModel.uid icon:_image success:^(id result) {
  255 + [QMUITips hideAllToastInView:self.superview animated:YES];
  256 + NSLog(@"result:%@",result);
  257 + NSString *deFaceUrl = result[@"data"][@"faceUrl"];
  258 + NSString *faceUrl = @"";
  259 + if ([deFaceUrl containsString:@"/mobile/images/mobilehead/default/"]) {
  260 + faceUrl = CNLiveNetAddDefaultHead;
  261 + }else{
  262 + faceUrl = deFaceUrl;
  263 + }
  264 + CNUserShareModel.faceUrl = faceUrl;
  265 + [self.head setImage:self->_image forState:UIControlStateNormal];
  266 +
  267 + } failure:^(NSDictionary *errorDic) {
  268 + [QMUITips hideAllToastInView:self.superview animated:YES];
  269 + [QMUITips showError:errorDic[@"errorMessage"] inView:self.superview hideAfterDelay:timeValue];
  270 + }];
  271 +
  272 +}
  273 +
  274 +// 修改名字
  275 +- (void)modifyNickName {
  276 + [QMUITips showLoading:@"修改中" inView:self.superview];
237 __weak typeof(self) weakSelf = self; 277 __weak typeof(self) weakSelf = self;
238 -// [XWUserRequest updateUserInfoWithUid:User_ID name:_nickname.text head:_image success:^(id _Nonnull result) {  
239 -// btn.userInteractionEnabled = YES;  
240 -// __strong typeof(weakSelf) strongSelf = weakSelf;  
241 -// if(!strongSelf) return;  
242 -// if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(loginSuccess:result:)]) {  
243 -// [strongSelf.delegate loginSuccess:strongSelf result:result];  
244 -//  
245 -// }  
246 -//  
247 -// } failure:^(NSDictionary * _Nonnull errorDic) {  
248 -// btn.userInteractionEnabled = YES;  
249 -// __strong typeof(weakSelf) strongSelf = weakSelf;  
250 -// if(!strongSelf) return;  
251 -// [XWAlertView alertErrorViewWithTextMessage:@"登录失败"];  
252 -// }]; 278 + [CNLiveUserSystemCenter modifyUserInfoType:UserInfoTypeNickName uid:CNUserShareModel.uid modifyInfo:_nickname.text success:^(id result) {
  279 + __strong typeof(weakSelf) strongSelf = weakSelf;
  280 + if(!strongSelf) return;
  281 + strongSelf.next.userInteractionEnabled = YES;
  282 + CNUserShareModel.nickname = strongSelf.nickname.text;
  283 + [QMUITips hideAllToastInView:strongSelf.superview animated:YES];
  284 + if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(loginSuccess:result:)]) {
  285 + [strongSelf.delegate loginSuccess:strongSelf result:result];
  286 + }
  287 +
  288 + [QMUITips showLoading:@"正在连接服务器..." inView:strongSelf.superview];
  289 + [strongSelf syncIM];
  290 +
  291 + } failure:^(NSDictionary *errorDic) {
  292 + __strong typeof(weakSelf) strongSelf = weakSelf;
  293 + if(!strongSelf) return;
  294 + strongSelf.next.userInteractionEnabled = YES;
  295 + [QMUITips hideAllToastInView:strongSelf.superview animated:YES];
  296 + [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:strongSelf.superview hideAfterDelay:timeValue];
  297 + }];
  298 +
  299 +}
  300 +
  301 +// 连接IM
  302 +- (void)syncIM {
  303 + [CNLiveLoginRequestModel getTIMLoginToken:CNUserShareModel.uid successBlock:^(NSString *token) {
  304 + self.loginParam.identifier = CNUserShareModel.uid;
  305 + self.loginParam.userSig = token;
  306 + self.loginParam.tokenTime = [[NSDate date] timeIntervalSince1970];
  307 +
  308 + [[IMAPlatform sharedInstance] login:self.loginParam succ:^{
  309 + [QMUITips hideAllToastInView:self.superview animated:YES];
  310 + [NBSAppAgent setUserIdentifier:[CNLiveBusinessTools getSidIdfv]];
  311 + [self.loginParam saveToLocal];
  312 +// [[AppDelegate sharedAppDelegate] registNotification];
  313 + [[IMAPlatform sharedInstance] configHost:self.loginParam];
  314 +
  315 +// [[AppDelegate sharedAppDelegate] enterMainUI];
253 316
  317 + //游客浏览后登陆
  318 +// [self showTouristsLoginTipsView];
  319 +
  320 + [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{
  321 + NSLog(@"asyncSetAllowType Suc");
  322 + [self.loginParam saveToLocal];
  323 + } fail:^(int code, NSString *msg) {
  324 + NSLog(@"asyncSetAllowType failed : %@", msg);
  325 + }];
  326 +
  327 + } fail:^(int code, NSString *msg) {
  328 + NSLog(@"login failed : %@", msg);
  329 + [QMUITips hideAllToastInView:self.superview animated:YES];
  330 + [QMUITips showError:msg inView:self.superview hideAfterDelay:timeValue];
  331 + }];
  332 +
  333 + } failedBlock:^(int code, NSString *errorMsg) {
  334 + NSLog(@"token code:%d error:%@", code, errorMsg);
  335 + [QMUITips hideAllToastInView:self.superview animated:YES];
  336 + [QMUITips showError:errorMsg inView:self.superview hideAfterDelay:timeValue];
  337 + }];
  338 +
254 } 339 }
255 340
256 /* 341 /*
@@ -277,92 +362,4 @@ static const NSInteger timeValue = 1.5; @@ -277,92 +362,4 @@ static const NSInteger timeValue = 1.5;
277 return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil]; 362 return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
278 } 363 }
279 364
280 -- (void)getAVAuthorizationStatus:(void (^)(void))block{  
281 - AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];  
282 - if (device) {  
283 - AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];  
284 - switch (status) {  
285 - case AVAuthorizationStatusNotDetermined: {  
286 - [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {  
287 - if (granted) {  
288 - dispatch_sync(dispatch_get_main_queue(), ^{  
289 - block();  
290 - });  
291 - NSLog(@"用户第一次同意了访问相机权限 - - %@", [NSThread currentThread]);  
292 - } else {  
293 - NSLog(@"用户第一次拒绝了访问相机权限 - - %@", [NSThread currentThread]);  
294 - }  
295 - }];  
296 - break;  
297 - }  
298 - case AVAuthorizationStatusAuthorized: {  
299 - block();  
300 - break;  
301 - }  
302 - case AVAuthorizationStatusDenied: {  
303 - NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];  
304 - NSString *app_Name = [infoDict objectForKey:@"CFBundleDisplayName"];  
305 - if (app_Name == nil) {  
306 - app_Name = [infoDict objectForKey:@"CFBundleName"];  
307 - }  
308 - NSString *messageString = [NSString stringWithFormat:@"请在iPhone的\"设置 - 隐私 - 相机\"选项中,允许%@访问你的相机", app_Name];  
309 - UIAlertController *alertC = [UIAlertController alertControllerWithTitle:nil message:messageString preferredStyle:(UIAlertControllerStyleAlert)];  
310 - UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"好" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {  
311 -  
312 - }];  
313 -  
314 - [alertC addAction:alertA];  
315 - [(UIViewController *)self.delegate presentViewController:alertC animated:YES completion:nil];  
316 - break;  
317 - }  
318 - case AVAuthorizationStatusRestricted: {  
319 - NSLog(@"因为系统原因, 无法访问相册");  
320 - break;  
321 - }  
322 -  
323 - default:  
324 - break;  
325 - }  
326 - return;  
327 - }  
328 - [QMUITips showError:@"未检测到您的摄像头" inView:self.superview hideAfterDelay:timeValue];  
329 -}  
330 -  
331 -- (void)getPHAuthorizationStatus:(void (^)(void))block{  
332 - // 1.获取当前App的相册授权状态  
333 - PHAuthorizationStatus authorizationStatus = [PHPhotoLibrary authorizationStatus];  
334 -  
335 - // 2.判断授权状态  
336 - if (authorizationStatus == PHAuthorizationStatusAuthorized) {  
337 - // 2.1 如果已经授权, 保存图片(调用步骤2的方法)  
338 - block();  
339 -  
340 - } else if (authorizationStatus == PHAuthorizationStatusNotDetermined) { // 如果没决定, 弹出指示框, 让用户选择  
341 - [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {  
342 - // 如果用户选择授权, 则保存图片  
343 - if (status == PHAuthorizationStatusAuthorized) {  
344 - dispatch_async(dispatch_get_main_queue(), ^{  
345 - block();  
346 - });  
347 - }  
348 - }];  
349 -  
350 - } else {  
351 - NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];  
352 - NSString *app_Name = [infoDict objectForKey:@"CFBundleDisplayName"];  
353 - if (app_Name == nil) {  
354 - app_Name = [infoDict objectForKey:@"CFBundleName"];  
355 - }  
356 - NSString *messageString = [NSString stringWithFormat:@"请在iPhone的\"设置 - 隐私 - 相机\"选项中,允许%@访问你的相册", app_Name];  
357 - UIAlertController *alertC = [UIAlertController alertControllerWithTitle:nil message:messageString preferredStyle:(UIAlertControllerStyleAlert)];  
358 - UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"好" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {  
359 -  
360 - }];  
361 -  
362 - [alertC addAction:alertA];  
363 - [(UIViewController *)self.delegate presentViewController:alertC animated:YES completion:nil];  
364 - }  
365 -}  
366 -  
367 -  
368 @end 365 @end
Example/CNLiveLoginModule.xcodeproj/project.pbxproj
@@ -207,8 +207,8 @@ @@ -207,8 +207,8 @@
207 6003F586195388D20070C39A /* Sources */, 207 6003F586195388D20070C39A /* Sources */,
208 6003F587195388D20070C39A /* Frameworks */, 208 6003F587195388D20070C39A /* Frameworks */,
209 6003F588195388D20070C39A /* Resources */, 209 6003F588195388D20070C39A /* Resources */,
210 - CA7AE7B7AD9C2BF31675019E /* [CP] Embed Pods Frameworks */,  
211 - 52D60AE0F4D44D07B879A8CD /* [CP] Copy Pods Resources */, 210 + 9E665687E99D8511B3D85BB7 /* [CP] Embed Pods Frameworks */,
  211 + ED94DF5FADC63D17850E55EE /* [CP] Copy Pods Resources */,
212 ); 212 );
213 buildRules = ( 213 buildRules = (
214 ); 214 );
@@ -321,47 +321,7 @@ @@ -321,47 +321,7 @@
321 shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 321 shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
322 showEnvVarsInLog = 0; 322 showEnvVarsInLog = 0;
323 }; 323 };
324 - 52D60AE0F4D44D07B879A8CD /* [CP] Copy Pods Resources */ = {  
325 - isa = PBXShellScriptBuildPhase;  
326 - buildActionMask = 2147483647;  
327 - files = (  
328 - );  
329 - inputPaths = (  
330 - "${PODS_ROOT}/Target Support Files/Pods-CNLiveLoginModule_Example/Pods-CNLiveLoginModule_Example-resources.sh",  
331 - "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveLoginModule/CNLiveLoginModule.bundle",  
332 - );  
333 - name = "[CP] Copy Pods Resources";  
334 - outputPaths = (  
335 - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveLoginModule.bundle",  
336 - );  
337 - runOnlyForDeploymentPostprocessing = 0;  
338 - shellPath = /bin/sh;  
339 - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveLoginModule_Example/Pods-CNLiveLoginModule_Example-resources.sh\"\n";  
340 - showEnvVarsInLog = 0;  
341 - };  
342 - C744CFA8914B761288845DE6 /* [CP] Check Pods Manifest.lock */ = {  
343 - isa = PBXShellScriptBuildPhase;  
344 - buildActionMask = 2147483647;  
345 - files = (  
346 - );  
347 - inputFileListPaths = (  
348 - );  
349 - inputPaths = (  
350 - "${PODS_PODFILE_DIR_PATH}/Podfile.lock",  
351 - "${PODS_ROOT}/Manifest.lock",  
352 - );  
353 - name = "[CP] Check Pods Manifest.lock";  
354 - outputFileListPaths = (  
355 - );  
356 - outputPaths = (  
357 - "$(DERIVED_FILE_DIR)/Pods-CNLiveLoginModule_Example-checkManifestLockResult.txt",  
358 - );  
359 - runOnlyForDeploymentPostprocessing = 0;  
360 - shellPath = /bin/sh;  
361 - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";  
362 - showEnvVarsInLog = 0;  
363 - };  
364 - CA7AE7B7AD9C2BF31675019E /* [CP] Embed Pods Frameworks */ = { 324 + 9E665687E99D8511B3D85BB7 /* [CP] Embed Pods Frameworks */ = {
365 isa = PBXShellScriptBuildPhase; 325 isa = PBXShellScriptBuildPhase;
366 buildActionMask = 2147483647; 326 buildActionMask = 2147483647;
367 files = ( 327 files = (
@@ -374,6 +334,7 @@ @@ -374,6 +334,7 @@
374 "${BUILT_PRODUCTS_DIR}/CNLiveBaseTools/CNLiveBaseTools.framework", 334 "${BUILT_PRODUCTS_DIR}/CNLiveBaseTools/CNLiveBaseTools.framework",
375 "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework", 335 "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework",
376 "${BUILT_PRODUCTS_DIR}/CNLiveBusinessTools/CNLiveBusinessTools.framework", 336 "${BUILT_PRODUCTS_DIR}/CNLiveBusinessTools/CNLiveBusinessTools.framework",
  337 + "${BUILT_PRODUCTS_DIR}/CNLiveCacheManagerKit/CNLiveCacheManagerKit.framework",
377 "${BUILT_PRODUCTS_DIR}/CNLiveChooseCountry/CNLiveChooseCountry.framework", 338 "${BUILT_PRODUCTS_DIR}/CNLiveChooseCountry/CNLiveChooseCountry.framework",
378 "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework", 339 "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework",
379 "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", 340 "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework",
@@ -384,6 +345,7 @@ @@ -384,6 +345,7 @@
384 "${BUILT_PRODUCTS_DIR}/CNLiveUploadManager/CNLiveUploadManager.framework", 345 "${BUILT_PRODUCTS_DIR}/CNLiveUploadManager/CNLiveUploadManager.framework",
385 "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework", 346 "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework",
386 "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework", 347 "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework",
  348 + "${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
387 "${BUILT_PRODUCTS_DIR}/HappyDNS/HappyDNS.framework", 349 "${BUILT_PRODUCTS_DIR}/HappyDNS/HappyDNS.framework",
388 "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework", 350 "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework",
389 "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", 351 "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework",
@@ -391,6 +353,7 @@ @@ -391,6 +353,7 @@
391 "${BUILT_PRODUCTS_DIR}/Qiniu/Qiniu.framework", 353 "${BUILT_PRODUCTS_DIR}/Qiniu/Qiniu.framework",
392 "${BUILT_PRODUCTS_DIR}/SDAutoLayout/SDAutoLayout.framework", 354 "${BUILT_PRODUCTS_DIR}/SDAutoLayout/SDAutoLayout.framework",
393 "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", 355 "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework",
  356 + "${PODS_ROOT}/TXIMSDK_iOS/ImSDK.framework",
394 "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework", 357 "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework",
395 ); 358 );
396 name = "[CP] Embed Pods Frameworks"; 359 name = "[CP] Embed Pods Frameworks";
@@ -401,6 +364,7 @@ @@ -401,6 +364,7 @@
401 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseTools.framework", 364 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseTools.framework",
402 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework", 365 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework",
403 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBusinessTools.framework", 366 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBusinessTools.framework",
  367 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCacheManagerKit.framework",
404 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveChooseCountry.framework", 368 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveChooseCountry.framework",
405 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework", 369 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework",
406 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", 370 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework",
@@ -411,6 +375,7 @@ @@ -411,6 +375,7 @@
411 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUploadManager.framework", 375 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUploadManager.framework",
412 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework", 376 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework",
413 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework", 377 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework",
  378 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
414 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HappyDNS.framework", 379 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HappyDNS.framework",
415 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework", 380 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework",
416 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", 381 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework",
@@ -418,6 +383,7 @@ @@ -418,6 +383,7 @@
418 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Qiniu.framework", 383 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Qiniu.framework",
419 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDAutoLayout.framework", 384 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDAutoLayout.framework",
420 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", 385 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
  386 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ImSDK.framework",
421 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework", 387 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework",
422 ); 388 );
423 runOnlyForDeploymentPostprocessing = 0; 389 runOnlyForDeploymentPostprocessing = 0;
@@ -425,6 +391,46 @@ @@ -425,6 +391,46 @@
425 shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveLoginModule_Example/Pods-CNLiveLoginModule_Example-frameworks.sh\"\n"; 391 shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveLoginModule_Example/Pods-CNLiveLoginModule_Example-frameworks.sh\"\n";
426 showEnvVarsInLog = 0; 392 showEnvVarsInLog = 0;
427 }; 393 };
  394 + C744CFA8914B761288845DE6 /* [CP] Check Pods Manifest.lock */ = {
  395 + isa = PBXShellScriptBuildPhase;
  396 + buildActionMask = 2147483647;
  397 + files = (
  398 + );
  399 + inputFileListPaths = (
  400 + );
  401 + inputPaths = (
  402 + "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
  403 + "${PODS_ROOT}/Manifest.lock",
  404 + );
  405 + name = "[CP] Check Pods Manifest.lock";
  406 + outputFileListPaths = (
  407 + );
  408 + outputPaths = (
  409 + "$(DERIVED_FILE_DIR)/Pods-CNLiveLoginModule_Example-checkManifestLockResult.txt",
  410 + );
  411 + runOnlyForDeploymentPostprocessing = 0;
  412 + shellPath = /bin/sh;
  413 + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
  414 + showEnvVarsInLog = 0;
  415 + };
  416 + ED94DF5FADC63D17850E55EE /* [CP] Copy Pods Resources */ = {
  417 + isa = PBXShellScriptBuildPhase;
  418 + buildActionMask = 2147483647;
  419 + files = (
  420 + );
  421 + inputPaths = (
  422 + "${PODS_ROOT}/Target Support Files/Pods-CNLiveLoginModule_Example/Pods-CNLiveLoginModule_Example-resources.sh",
  423 + "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveLoginModule/CNLiveLoginModule.bundle",
  424 + );
  425 + name = "[CP] Copy Pods Resources";
  426 + outputPaths = (
  427 + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveLoginModule.bundle",
  428 + );
  429 + runOnlyForDeploymentPostprocessing = 0;
  430 + shellPath = /bin/sh;
  431 + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveLoginModule_Example/Pods-CNLiveLoginModule_Example-resources.sh\"\n";
  432 + showEnvVarsInLog = 0;
  433 + };
428 /* End PBXShellScriptBuildPhase section */ 434 /* End PBXShellScriptBuildPhase section */
429 435
430 /* Begin PBXSourcesBuildPhase section */ 436 /* Begin PBXSourcesBuildPhase section */
Example/CNLiveLoginModule/CNLIVEAppDelegate.m
@@ -28,26 +28,26 @@ @@ -28,26 +28,26 @@
28 } 28 }
29 [self networkParamAction]; 29 [self networkParamAction];
30 30
31 -// [CNUserInfoManager saveUserinfoDic:@{  
32 -// @"bigFaceUrl":@"http://yweb0.cnliveimg.com/images/headImg/2019/1030/1572439148697.jpg",  
33 -// @"countryCode":@"86",  
34 -// @"email":@"",  
35 -// @"extInfo":@"",  
36 -// @"faceUrl":@"http://yweb0.cnliveimg.com/images/headImg/2019/1030/1572439148697_small.jpg",  
37 -// @"gender":@"m",  
38 -// @"hUid":@"",  
39 -// @"isNewUser":@"0",  
40 -// @"location":@"北京市海淀区",  
41 -// @"mobile":@"17600922519",  
42 -// @"nickName":@"金帝",  
43 -// @"platformId":@"769_jetj7bq525",  
44 -// @"qqUid":@"",  
45 -// @"renrenUid":@"",  
46 -// @"sinaUid":@"",  
47 -// @"token":@"RkFYeLkl/u5S7tW8UcOkT3rfLTP/Ua8NIkdEsKlcolvl/yxTMNbAYXmmJyhKGpkj",  
48 -// @"uid":@"10514405",  
49 -// @"wxUid":@""  
50 -// }]; 31 + [CNUserInfoManager saveUserinfoDic:@{
  32 + @"bigFaceUrl":@"http://yweb0.cnliveimg.com/images/headImg/2019/1030/1572439148697.jpg",
  33 + @"countryCode":@"86",
  34 + @"email":@"",
  35 + @"extInfo":@"",
  36 + @"faceUrl":@"http://yweb0.cnliveimg.com/images/headImg/2019/1030/1572439148697_small.jpg",
  37 + @"gender":@"m",
  38 + @"hUid":@"",
  39 + @"isNewUser":@"0",
  40 + @"location":@"北京市海淀区",
  41 + @"mobile":@"17600922519",
  42 + @"nickName":@"金帝",
  43 + @"platformId":@"769_jetj7bq525",
  44 + @"qqUid":@"",
  45 + @"renrenUid":@"",
  46 + @"sinaUid":@"",
  47 + @"token":@"RkFYeLkl/u5S7tW8UcOkT3rfLTP/Ua8NIkdEsKlcolvl/yxTMNbAYXmmJyhKGpkj",
  48 + @"uid":@"10514405",
  49 + @"wxUid":@""
  50 + }];
51 51
52 CNLiveLoginController *vc = [[CNLiveLoginController alloc] init]; 52 CNLiveLoginController *vc = [[CNLiveLoginController alloc] init];
53 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc]; 53 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];