Commit 8c8882792e309ea5043513f0729b6b5ef43d0ba0
1 parent
d78736da
no message
Showing
14 changed files
with
320 additions
and
56 deletions
CNLiveLoginModule/Classes/Controller/CNLiveLoginController.m
| ... | ... | @@ -97,10 +97,7 @@ |
| 97 | 97 | |
| 98 | 98 | }else{ |
| 99 | 99 | // 老用户 -> home |
| 100 | -// [XWAlertView alertSucceedViewWithTextMessage:@"登录成功" view:self.view block:^{ | |
| 101 | -// // 通知 | |
| 102 | -// [XWLoginNotification postUserLoginNotification:result]; | |
| 103 | -// }]; | |
| 100 | + | |
| 104 | 101 | } |
| 105 | 102 | |
| 106 | 103 | } |
| ... | ... | @@ -144,7 +141,7 @@ |
| 144 | 141 | _close = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 145 | 142 | _close.frame = CGRectMake(SCREEN_WIDTH-44-10, StatusBarHeight, 44, 44); |
| 146 | 143 | _close.hidden = !self.isShowClose; |
| 147 | - UIImage *image = [UIImage cn_getImageName:@"login_close" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 144 | + UIImage *image = [self getImageWithImageName:@"login_close" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 148 | 145 | [_close setImage:image forState:UIControlStateNormal]; |
| 149 | 146 | [_close addTarget:self action:@selector(closeDidSelected:) forControlEvents:UIControlEventTouchUpInside]; |
| 150 | 147 | _close.adjustsImageWhenHighlighted = NO; | ... | ... |
CNLiveLoginModule/Classes/Model/CNLiveClassifyOffsetManager.h
0 → 100644
| 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 | ... | ... |
CNLiveLoginModule/Classes/Model/CNLiveClassifyOffsetManager.m
0 → 100644
| 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 | ... | ... |
CNLiveLoginModule/Classes/Model/CNLiveLoginRequestModel.h
| ... | ... | @@ -9,9 +9,16 @@ |
| 9 | 9 | #import <Foundation/Foundation.h> |
| 10 | 10 | |
| 11 | 11 | NS_ASSUME_NONNULL_BEGIN |
| 12 | +typedef void (^TIMLoginSucc)(void); | |
| 13 | +typedef void (^TIMFail)(int code, NSString * msg); | |
| 12 | 14 | |
| 13 | 15 | @interface CNLiveLoginRequestModel : NSObject |
| 14 | -+ (void)getTIMLoginToken:(NSString *)identifier successBlock:(void (^)(NSString *))successBlock failedBlock:(void (^)(int, NSString *))errorBlock; | |
| 16 | ++ (instancetype)manager; | |
| 17 | + | |
| 18 | +- (void)getTIMLoginToken:(NSString *)identifier success:(void (^)(NSString *))success failed:(void (^)(int, NSString *))failed; | |
| 19 | + | |
| 20 | + | |
| 21 | +- (void)loginTIM:(NSString *)uid success:(TIMLoginSucc)success failed:(TIMFail)failed; | |
| 15 | 22 | |
| 16 | 23 | @end |
| 17 | 24 | ... | ... |
CNLiveLoginModule/Classes/Model/CNLiveLoginRequestModel.m
| ... | ... | @@ -7,15 +7,65 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import "CNLiveLoginRequestModel.h" |
| 10 | +#import <UIKit/UIKit.h> | |
| 11 | +#import "QMUIKit.h" | |
| 12 | + | |
| 10 | 13 | #import "CNUserInfoManager.h" |
| 11 | 14 | #import "CNLiveEnvironment.h" |
| 12 | 15 | #import <CNLiveRequestBastKit/CNLiveNetworking.h> |
| 16 | +#import "TIMAdapter.h" | |
| 17 | +#import "CommonLibrary.h" | |
| 18 | + | |
| 19 | +@interface CNLiveLoginRequestModel() | |
| 20 | +@property (nonatomic, strong) IMALoginParam *loginParam; | |
| 21 | + | |
| 22 | +@end | |
| 13 | 23 | |
| 14 | 24 | @implementation CNLiveLoginRequestModel |
| 25 | +#pragma mark - 单例 | |
| 26 | ++ (instancetype)manager { | |
| 27 | + static CNLiveLoginRequestModel *_singleton = nil; | |
| 28 | + static dispatch_once_t onceToken; | |
| 29 | + dispatch_once(&onceToken, ^{ | |
| 30 | + //不能再使用alloc方法 | |
| 31 | + //因为已经重写了allocWithZone方法,所以这里要调用父类的分配空间的方法 | |
| 32 | + _singleton = [[super allocWithZone:NULL] init]; | |
| 33 | + BOOL isAutoLogin = [IMAPlatform isAutoLogin]; | |
| 34 | + | |
| 35 | + if (isAutoLogin) { | |
| 36 | + _singleton.loginParam = [IMALoginParam loadFromLocal]; | |
| 37 | + | |
| 38 | + } else { | |
| 39 | + _singleton.loginParam = [[IMALoginParam alloc] init]; | |
| 40 | + | |
| 41 | + } | |
| 42 | + [IMAPlatform configWith:_singleton.loginParam.config]; | |
| 15 | 43 | |
| 16 | -//获取token | |
| 17 | -+ (void)getTIMLoginToken:(NSString *)identifier successBlock:(void (^)(NSString *))successBlock failedBlock:(void (^)(int, NSString *))errorBlock { | |
| 44 | + }); | |
| 45 | + return _singleton; | |
| 46 | + | |
| 47 | +} | |
| 48 | + | |
| 49 | +// 防止外部调用alloc 或者 new | |
| 50 | ++ (instancetype)allocWithZone:(struct _NSZone *)zone { | |
| 51 | + return [CNLiveLoginRequestModel manager]; | |
| 52 | + | |
| 53 | +} | |
| 54 | + | |
| 55 | +// 防止外部调用copy | |
| 56 | +- (id)copyWithZone:(nullable NSZone *)zone { | |
| 57 | + return [CNLiveLoginRequestModel manager]; | |
| 18 | 58 | |
| 59 | +} | |
| 60 | + | |
| 61 | +// 防止外部调用mutableCopy | |
| 62 | +- (id)mutableCopyWithZone:(nullable NSZone *)zone { | |
| 63 | + return [CNLiveLoginRequestModel manager]; | |
| 64 | + | |
| 65 | +} | |
| 66 | + | |
| 67 | +//获取token | |
| 68 | +- (void)getTIMLoginToken:(NSString *)identifier success:(void (^)(NSString *))success failed:(void (^)(int, NSString *))failed{ | |
| 19 | 69 | NSDictionary *params = @{@"appId":AppId, |
| 20 | 70 | @"plat":@"i", |
| 21 | 71 | @"sdkAppId":SdkAppId, |
| ... | ... | @@ -28,21 +78,84 @@ |
| 28 | 78 | if (responseObject && ![responseObject isKindOfClass:[NSNull class]] && [responseObject isKindOfClass:[NSDictionary class]] && [[responseObject allKeys] containsObject:@"data"] && [[responseObject objectForKey:@"data"] isKindOfClass:[NSDictionary class]]) { |
| 29 | 79 | NSNumber *code = responseObject[@"errorCode"]; |
| 30 | 80 | if (code && code.intValue == 0) { |
| 31 | - if (successBlock) { | |
| 32 | - successBlock(responseObject[@"data"][@"token"]); | |
| 81 | + if (success) { | |
| 82 | + success(responseObject[@"data"][@"token"]); | |
| 33 | 83 | } |
| 34 | 84 | } else { |
| 35 | - if (errorBlock) { | |
| 36 | - errorBlock(31012, @"获取token失败"); | |
| 85 | + if (failed) { | |
| 86 | + failed(31012, @"获取token失败"); | |
| 37 | 87 | } |
| 38 | 88 | } |
| 39 | 89 | |
| 40 | 90 | } |
| 41 | 91 | |
| 42 | 92 | }else{ |
| 43 | - if (errorBlock) errorBlock(31012,@"Token acquisition failure"); | |
| 93 | + if (failed) failed(31012,@"Token acquisition failure"); | |
| 44 | 94 | } |
| 45 | 95 | }]; |
| 46 | 96 | |
| 47 | 97 | } |
| 98 | + | |
| 99 | +- (void)loginTIM:(NSString *)uid success:(TIMLoginSucc)success failed:(TIMFail)failed{ | |
| 100 | + | |
| 101 | + [self getTIMLoginToken:uid success:^(NSString * _Nonnull token) { | |
| 102 | + self.loginParam.identifier = CNUserShareModel.uid; | |
| 103 | + self.loginParam.userSig = token; | |
| 104 | + self.loginParam.tokenTime = [[NSDate date] timeIntervalSince1970]; | |
| 105 | + | |
| 106 | + [[IMAPlatform sharedInstance] login:self.loginParam succ:^{ | |
| 107 | + | |
| 108 | +// [NBSAppAgent setUserIdentifier:[CNLiveBusinessTools getSidIdfv]]; | |
| 109 | + [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES]; | |
| 110 | + [QMUITips showSucceed:@"登录成功" inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:1.5]; | |
| 111 | + [self.loginParam saveToLocal]; | |
| 112 | +// [[AppDelegate sharedAppDelegate] registNotification]; | |
| 113 | + [[IMAPlatform sharedInstance] configHost:self.loginParam]; | |
| 114 | + [IMAPlatform sharedInstance].didConnectSuccess = YES; | |
| 115 | + //电商 | |
| 116 | + NSString *userID = CNUserShareModel.uid; | |
| 117 | +// [[DSCnliveShopSDKManager sharedManager] loginUser:userID]; | |
| 118 | + //设置APP已活跃 | |
| 119 | + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"]; | |
| 120 | + [[NSUserDefaults standardUserDefaults] synchronize]; | |
| 121 | + | |
| 122 | + [[IMAPlatform sharedInstance].contactMgr asyncUpdateContact]; | |
| 123 | + [[IMAPlatform sharedInstance].contactMgr saveGroupIdList:YES]; | |
| 124 | + [[IMAPlatform sharedInstance] configHost:self.loginParam]; | |
| 125 | + [IMAPlatform sharedInstance].didConnectSuccess = YES; | |
| 126 | + //电商 | |
| 127 | +// NSString *userID = CNUserShareModel.uid; | |
| 128 | +// [[DSCnliveShopSDKManager sharedManager] loginUser:userID]; | |
| 129 | + //设置APP已活跃 | |
| 130 | + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"]; | |
| 131 | + [[NSUserDefaults standardUserDefaults] synchronize]; | |
| 132 | + | |
| 133 | + [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{ | |
| 134 | + NSLog(@"asyncSetAllowType Suc"); | |
| 135 | + [self.loginParam saveToLocal]; | |
| 136 | + | |
| 137 | + } fail:^(int code, NSString *msg) { | |
| 138 | + NSLog(@"asyncSetAllowType failed : %@", msg); | |
| 139 | + }]; | |
| 140 | + success?success():@""; | |
| 141 | + | |
| 142 | + } fail:^(int code, NSString *msg) { | |
| 143 | + NSLog(@"login failed : %@", msg); | |
| 144 | + failed?failed(code, msg):@""; | |
| 145 | + | |
| 146 | + if (code == 6208) { | |
| 147 | + //离线被踢下线重新登录 | |
| 148 | +// [weakSelf resumeLogin]; | |
| 149 | + } | |
| 150 | + else | |
| 151 | + [QMUITips showError:msg inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:1.5]; | |
| 152 | + [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES]; | |
| 153 | + }]; | |
| 154 | + } failed:^(int code, NSString * _Nonnull msg) { | |
| 155 | + NSLog(@"token code:%d msg:%@", code, msg); | |
| 156 | + [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES]; | |
| 157 | + failed?failed(code, msg):@""; | |
| 158 | + }]; | |
| 159 | + | |
| 160 | +} | |
| 48 | 161 | @end | ... | ... |
CNLiveLoginModule/Classes/ThreeLogin/CNLiveBindingTelView.m
| ... | ... | @@ -79,7 +79,7 @@ static const NSInteger timeValue = 1.5; |
| 79 | 79 | countDown.dataSource = self; |
| 80 | 80 | countDown.delegate = self; |
| 81 | 81 | countDown.frame = CGRectMake(frame.size.width-80, account.bottom+space+10, 80, rowHeight-10); |
| 82 | - UIImage *image2 = [UIImage cn_getImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 82 | + UIImage *image2 = [self getImageWithImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 83 | 83 | [countDown setImage:image2 forState:UIControlStateNormal]; |
| 84 | 84 | countDown.adjustsImageWhenHighlighted = NO; |
| 85 | 85 | [countDown setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; |
| ... | ... | @@ -254,7 +254,7 @@ static const NSInteger timeValue = 1.5; |
| 254 | 254 | button.backgroundColor = [UIColor whiteColor]; |
| 255 | 255 | button.userInteractionEnabled = YES; |
| 256 | 256 | [button setTitle:@"" forState:UIControlStateNormal]; |
| 257 | - UIImage *image2 = [UIImage cn_getImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 257 | + UIImage *image2 = [self getImageWithImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 258 | 258 | [button setImage:image2 forState:UIControlStateNormal]; |
| 259 | 259 | } |
| 260 | 260 | ... | ... |
CNLiveLoginModule/Classes/ThreeLogin/CNLiveThreeLoginView.m
| ... | ... | @@ -57,7 +57,7 @@ static NSInteger const rowHeight = 80; |
| 57 | 57 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 58 | 58 | btn.tag = 10000+i; |
| 59 | 59 | btn.frame = CGRectMake(btnWidth*i, name.bottom, btnWidth, rowHeight); |
| 60 | - UIImage *image = [UIImage cn_getImageName:pics[i] bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 60 | + UIImage *image = [self getImageWithImageName:pics[i] bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 61 | 61 | [btn setImage:image forState:UIControlStateNormal]; |
| 62 | 62 | btn.adjustsImageWhenHighlighted = NO; |
| 63 | 63 | [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside]; | ... | ... |
CNLiveLoginModule/Classes/View/CNLiveCompleteInfoView.m
| ... | ... | @@ -62,7 +62,7 @@ static const NSInteger timeValue = 1.5; |
| 62 | 62 | head.layer.cornerRadius = 40; |
| 63 | 63 | head.layer.masksToBounds = YES; |
| 64 | 64 | head.adjustsImageWhenHighlighted = NO; |
| 65 | - UIImage *image = [UIImage cn_getImageName:@"login_camera" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 65 | + UIImage *image = [self getImageWithImageName:@"login_camera" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 66 | 66 | [head setImage:image forState:UIControlStateNormal]; |
| 67 | 67 | [head addTarget:self action:@selector(headDidClicked:) forControlEvents:UIControlEventTouchUpInside]; |
| 68 | 68 | [self addSubview:head]; | ... | ... |
CNLiveLoginModule/Classes/View/CNLiveLoginCountryView.m
| ... | ... | @@ -47,7 +47,7 @@ |
| 47 | 47 | [code setTitle:[NSString stringWithFormat:@"+%@",_countryCode] forState:UIControlStateNormal]; |
| 48 | 48 | [code setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal]; |
| 49 | 49 | code.titleLabel.font = [UIFont systemFontOfSize:14]; |
| 50 | - UIImage *image = [UIImage cn_getImageName:@"login_country" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 50 | + UIImage *image = [self getImageWithImageName:@"login_country" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 51 | 51 | [code setImage:image forState:UIControlStateNormal]; |
| 52 | 52 | code.adjustsImageWhenHighlighted = NO; |
| 53 | 53 | //button图片的偏移量,距上左下右分别(0, 0, 0, 0)像素点 | ... | ... |
CNLiveLoginModule/Classes/View/CNLiveLoginNavigationBar.m
| ... | ... | @@ -60,7 +60,7 @@ static const NSInteger margin = 15; |
| 60 | 60 | _left= [UIButton buttonWithType:UIButtonTypeCustom]; |
| 61 | 61 | _left.adjustsImageWhenHighlighted = NO; |
| 62 | 62 | _left.frame = CGRectMake(margin, StatusBarHeight, NavigationBarHeight, NavigationBarHeight); |
| 63 | - UIImage *image = [UIImage cn_getImageName:@"mine_back_black_b" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 63 | + UIImage *image = [self getImageWithImageName:@"mine_back_black_b" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 64 | 64 | [_left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal]; |
| 65 | 65 | _left.titleLabel.font = [UIFont systemFontOfSize:15]; |
| 66 | 66 | [_left setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; | ... | ... |
CNLiveLoginModule/Classes/View/CNLiveLoginView.m
| ... | ... | @@ -16,6 +16,10 @@ |
| 16 | 16 | #import "CNUserInfoManager.h" |
| 17 | 17 | #import "CNLiveEnvironment.h" |
| 18 | 18 | #import "CNLiveCategory.h" |
| 19 | +#import "TIMAdapter.h" | |
| 20 | +#import "CommonLibrary.h" | |
| 21 | + | |
| 22 | +#import "CNLiveLoginRequestModel.h" | |
| 19 | 23 | |
| 20 | 24 | #import "CNLiveLoginCountryView.h" |
| 21 | 25 | #import "CNLiveLoginTextField.h" |
| ... | ... | @@ -57,7 +61,7 @@ static const NSInteger timeValue = 1.5; |
| 57 | 61 | } |
| 58 | 62 | - (void)createSubviews:(CGRect)frame{ |
| 59 | 63 | UIImageView *logo = [[UIImageView alloc] initWithFrame:CGRectMake((frame.size.width-75)/2.0, 0, 75, 100)]; |
| 60 | - UIImage *image = [UIImage cn_getImageName:@"login_logo" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 64 | + UIImage *image = [self getImageWithImageName:@"login_logo" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 61 | 65 | logo.image = image; |
| 62 | 66 | [self addSubview:logo]; |
| 63 | 67 | self.logo = logo; |
| ... | ... | @@ -97,7 +101,7 @@ static const NSInteger timeValue = 1.5; |
| 97 | 101 | countDown.dataSource = self; |
| 98 | 102 | countDown.delegate = self; |
| 99 | 103 | countDown.frame = CGRectMake(frame.size.width-80, account.bottom+space+10, 80, rowHeight-10); |
| 100 | - UIImage *image2 = [UIImage cn_getImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 104 | + UIImage *image2 = [self getImageWithImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 101 | 105 | [countDown setImage:image2 forState:UIControlStateNormal]; |
| 102 | 106 | countDown.adjustsImageWhenHighlighted = NO; |
| 103 | 107 | [countDown setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; |
| ... | ... | @@ -262,8 +266,7 @@ static const NSInteger timeValue = 1.5; |
| 262 | 266 | button.backgroundColor = [UIColor colorWithRed:222/255.0 green:222/255.0 blue:222/255.0 alpha:1.0]; |
| 263 | 267 | button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10); |
| 264 | 268 | [button setImage:nil forState:UIControlStateNormal]; |
| 265 | - NSString *title = [NSString stringWithFormat:@"%d秒后重新发送", 60]; | |
| 266 | - [button setTitle:title forState:UIControlStateNormal]; | |
| 269 | + [button setTitle:[NSString stringWithFormat:@"%d秒后重新发送", 60] forState:UIControlStateNormal]; | |
| 267 | 270 | [button startCountDown]; |
| 268 | 271 | |
| 269 | 272 | } failure:^(NSDictionary *errorDic) { |
| ... | ... | @@ -297,7 +300,7 @@ static const NSInteger timeValue = 1.5; |
| 297 | 300 | button.backgroundColor = [UIColor whiteColor]; |
| 298 | 301 | button.userInteractionEnabled = YES; |
| 299 | 302 | [button setTitle:@"" forState:UIControlStateNormal]; |
| 300 | - UIImage *image2 = [UIImage cn_getImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 303 | + UIImage *image2 = [self getImageWithImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 301 | 304 | [button setImage:image2 forState:UIControlStateNormal]; |
| 302 | 305 | } |
| 303 | 306 | |
| ... | ... | @@ -332,30 +335,107 @@ static const NSInteger timeValue = 1.5; |
| 332 | 335 | if(!strongSelf) return; |
| 333 | 336 | [QMUITips hideAllToastInView:strongSelf.superview animated:YES]; |
| 334 | 337 | [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:strongSelf.superview hideAfterDelay:timeValue]; |
| 335 | - // YES 新用户 NO 老用户 | |
| 336 | - BOOL isNewUser = YES; | |
| 337 | - if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:isNewUser:result:)]) { | |
| 338 | - [self.delegate loginSuccess:self isNewUser:isNewUser result:nil]; | |
| 339 | - } | |
| 340 | 338 | }]; |
| 341 | 339 | } |
| 342 | 340 | |
| 343 | 341 | #pragma mark - 连接IM |
| 344 | 342 | - (void)connectionIM:(id)result{ |
| 345 | - NSMutableDictionary *resDic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]]; | |
| 346 | - NSString *deFaceUrl = [resDic objectForKey:@"faceUrl"]; | |
| 347 | - NSString *faceUrl = @""; | |
| 348 | - if ([deFaceUrl containsString:@"/mobile/images/mobilehead/default/"]) { | |
| 349 | - faceUrl = CNLiveNetAddDefaultHead;//网家家默认头像地址 | |
| 350 | - [resDic setValue:faceUrl forKey:@"faceUrl"]; | |
| 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"]; | |
| 351 | 348 | } |
| 352 | - [CNUserInfoManager saveUserinfoDic:resDic]; | |
| 349 | + [CNUserInfoManager saveUserinfoDic:dic]; | |
| 350 | + | |
| 351 | +// // YES 新用户 NO 老用户 | |
| 352 | +// BOOL isNewUser = [dic[@"isNewUser"] intValue] != 0; | |
| 353 | +// if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:isNewUser:result:)]) { | |
| 354 | +// [self.delegate loginSuccess:self isNewUser:isNewUser result:result]; | |
| 355 | +// } | |
| 356 | + | |
| 357 | + [CNLiveLoginRequestModel getTIMLoginToken:CNUserShareModel.uid successBlock:^(NSString *token) { | |
| 358 | + | |
| 359 | + _loginParam.identifier = CNUserShareModel.uid; | |
| 360 | + _loginParam.userSig = token; | |
| 361 | + _loginParam.tokenTime = [[NSDate date] timeIntervalSince1970]; | |
| 362 | + | |
| 363 | + [[IMAPlatform sharedInstance] login:_loginParam succ:^{ | |
| 364 | + | |
| 365 | +// [NBSAppAgent setUserIdentifier:[CNLiveBusinessTools getSidIdfv]]; | |
| 366 | + [QMUITips hideAllToastInView:self.superview animated:YES]; | |
| 367 | + [QMUITips showSucceed:@"登录成功" inView:self.superview hideAfterDelay:1.5]; | |
| 368 | + [_loginParam saveToLocal]; | |
| 369 | +// [[AppDelegate sharedAppDelegate] registNotification]; | |
| 370 | + [[IMAPlatform sharedInstance] configHost:_loginParam]; | |
| 371 | + [IMAPlatform sharedInstance].didConnectSuccess = YES; | |
| 372 | + //电商 | |
| 373 | + NSString *userID = CNUserShareModel.uid; | |
| 374 | +// [[DSCnliveShopSDKManager sharedManager] loginUser:userID]; | |
| 375 | + //设置APP已活跃 | |
| 376 | + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"]; | |
| 377 | + [[NSUserDefaults standardUserDefaults] synchronize]; | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + if ([result[@"data"][@"isNewUser"] intValue] == 0) { | |
| 382 | + //老用户 | |
| 383 | +// [[AppDelegate sharedAppDelegate] enterMainUI]; | |
| 384 | +// [[AppDelegate sharedAppDelegate] registNotification]; | |
| 385 | + [[IMAPlatform sharedInstance].contactMgr asyncUpdateContact]; | |
| 386 | + [[IMAPlatform sharedInstance].contactMgr saveGroupIdList:YES]; | |
| 387 | + [[IMAPlatform sharedInstance] configHost:_loginParam]; | |
| 388 | + [IMAPlatform sharedInstance].didConnectSuccess = YES; | |
| 389 | + //电商 | |
| 390 | + NSString *userID = CNUserShareModel.uid; | |
| 391 | +// [[DSCnliveShopSDKManager sharedManager] loginUser:userID]; | |
| 392 | + //设置APP已活跃 | |
| 393 | + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"]; | |
| 394 | + [[NSUserDefaults standardUserDefaults] synchronize]; | |
| 395 | + | |
| 396 | + } | |
| 397 | + else { | |
| 398 | + //新用户 | |
| 399 | +// [OpenInstallSDK reportRegister]; | |
| 400 | +// CNLoginIUsernfoViewController *vc = [[CNLoginIUsernfoViewController alloc] init]; | |
| 401 | +// NSString *tel = _accountTextF.text; | |
| 402 | +// if(_accountTextF.text.length == 11){ | |
| 403 | +// tel = [_accountTextF.text stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"XXXX"]; | |
| 404 | +// } | |
| 405 | +// NSLog(@"tel:%@",tel); | |
| 406 | +// vc.mobileStr = tel; | |
| 407 | +// [self presentViewController:vc animated:NO completion:NULL]; | |
| 408 | + } | |
| 409 | +// [[NSNotificationCenter defaultCenter] postNotificationName:kCNLive_LoginSuccess object:nil]; | |
| 410 | + | |
| 411 | +// [CNDSShopActionViewModel networkParamAction]; | |
| 412 | + | |
| 413 | + [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{ | |
| 414 | + NSLog(@"asyncSetAllowType Suc"); | |
| 415 | + [_loginParam saveToLocal]; | |
| 416 | + | |
| 417 | + } fail:^(int code, NSString *msg) { | |
| 418 | + NSLog(@"asyncSetAllowType failed : %@", msg); | |
| 419 | + }]; | |
| 420 | + // [self dismissViewControllerAnimated:YES completion:nil]; | |
| 421 | + | |
| 422 | + } fail:^(int code, NSString *msg) { | |
| 423 | + NSLog(@"login failed : %@", msg); | |
| 424 | + if (code == 6208) { | |
| 425 | + //离线被踢下线重新登录 | |
| 426 | +// [weakSelf resumeLogin]; | |
| 427 | + } | |
| 428 | + else | |
| 429 | + [QMUITips showError:msg inView:self.superview hideAfterDelay:1.5]; | |
| 430 | + [QMUITips hideAllToastInView:self.superview animated:YES]; | |
| 431 | + }]; | |
| 432 | + | |
| 433 | + } failedBlock:^(int code, NSString *errorMsg) { | |
| 434 | + NSLog(@"token code:%d error:%@", code, errorMsg); | |
| 435 | + [QMUITips hideAllToastInView:self.superview animated:YES]; | |
| 436 | + | |
| 437 | + }]; | |
| 353 | 438 | |
| 354 | - // YES 新用户 NO 老用户 | |
| 355 | - BOOL isNewUser = YES; | |
| 356 | - if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:isNewUser:result:)]) { | |
| 357 | - [self.delegate loginSuccess:self isNewUser:isNewUser result:result]; | |
| 358 | - } | |
| 359 | 439 | } |
| 360 | 440 | |
| 361 | 441 | @end | ... | ... |
Example/CNLiveLoginModule.xcodeproj/project.pbxproj
| ... | ... | @@ -575,7 +575,7 @@ |
| 575 | 575 | GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch"; |
| 576 | 576 | INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist"; |
| 577 | 577 | MODULE_NAME = ExampleApp; |
| 578 | - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd.CNLiveLoginModule; | |
| 578 | + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd; | |
| 579 | 579 | PRODUCT_NAME = "登录模块"; |
| 580 | 580 | SWIFT_VERSION = 4.0; |
| 581 | 581 | WRAPPER_EXTENSION = app; |
| ... | ... | @@ -592,7 +592,7 @@ |
| 592 | 592 | GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch"; |
| 593 | 593 | INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist"; |
| 594 | 594 | MODULE_NAME = ExampleApp; |
| 595 | - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd.CNLiveLoginModule; | |
| 595 | + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd; | |
| 596 | 596 | PRODUCT_NAME = "登录模块"; |
| 597 | 597 | SWIFT_VERSION = 4.0; |
| 598 | 598 | WRAPPER_EXTENSION = app; | ... | ... |
Example/CNLiveLoginModule/CNLIVEAppDelegate.m
| ... | ... | @@ -48,6 +48,7 @@ |
| 48 | 48 | @"uid":@"10514405", |
| 49 | 49 | @"wxUid":@"" |
| 50 | 50 | }]; |
| 51 | + [[NSUserDefaults standardUserDefaults] setObject:@"RkFYeLkl/u5S7tW8UcOkT3rfLTP/Ua8NIkdEsKlcolvl/yxTMNbAYXmmJyhKGpkj" forKey:@"CNLiveAuthToken"]; | |
| 51 | 52 | |
| 52 | 53 | CNLiveLoginController *vc = [[CNLiveLoginController alloc] init]; |
| 53 | 54 | vc.isShowClose = YES; | ... | ... |
Example/CNLiveLoginModule/CNLiveLoginModule-Info.plist
| ... | ... | @@ -2,19 +2,6 @@ |
| 2 | 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 3 | 3 | <plist version="1.0"> |
| 4 | 4 | <dict> |
| 5 | - <key>NSAppTransportSecurity</key> | |
| 6 | - <dict> | |
| 7 | - <key>NSAllowsArbitraryLoads</key> | |
| 8 | - <true/> | |
| 9 | - </dict> | |
| 10 | - <key>NSCameraUsageDescription</key> | |
| 11 | - <string>App需要您的同意,才能访问相机</string> | |
| 12 | - <key>NSMicrophoneUsageDescription</key> | |
| 13 | - <string>App需要您的同意,才能访问麦克风</string> | |
| 14 | - <key>NSPhotoLibraryAddUsageDescription</key> | |
| 15 | - <string>App需要您的同意,才能访问相册</string> | |
| 16 | - <key>NSPhotoLibraryUsageDescription</key> | |
| 17 | - <string>App需要您的同意,才能访问相册</string> | |
| 18 | 5 | <key>CFBundleDevelopmentRegion</key> |
| 19 | 6 | <string>en</string> |
| 20 | 7 | <key>CFBundleDisplayName</key> |
| ... | ... | @@ -37,6 +24,19 @@ |
| 37 | 24 | <string>1.0</string> |
| 38 | 25 | <key>LSRequiresIPhoneOS</key> |
| 39 | 26 | <true/> |
| 27 | + <key>NSAppTransportSecurity</key> | |
| 28 | + <dict> | |
| 29 | + <key>NSAllowsArbitraryLoads</key> | |
| 30 | + <true/> | |
| 31 | + </dict> | |
| 32 | + <key>NSCameraUsageDescription</key> | |
| 33 | + <string>App需要您的同意,才能访问相机</string> | |
| 34 | + <key>NSMicrophoneUsageDescription</key> | |
| 35 | + <string>App需要您的同意,才能访问麦克风</string> | |
| 36 | + <key>NSPhotoLibraryAddUsageDescription</key> | |
| 37 | + <string>App需要您的同意,才能访问相册</string> | |
| 38 | + <key>NSPhotoLibraryUsageDescription</key> | |
| 39 | + <string>App需要您的同意,才能访问相册</string> | |
| 40 | 40 | <key>UILaunchStoryboardName</key> |
| 41 | 41 | <string>LaunchScreen</string> |
| 42 | 42 | <key>UIMainStoryboardFile</key> | ... | ... |