CNLiveUserSystemCenter.m
6.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//
// CNLiveUserSystemCenter.m
// CNLiveUserSystemDemo
//
// Created by iOS on 16/9/12.
// Copyright © 2016年 zhulin. All rights reserved.
//
#import "CNLiveUserSystemCenter.h"
#import "CNLiveLogin.h"
#import "CNLiveRegister.h"
#import "CNLiveVerificationCode.h"
#import "CNLiveFeedback.h"
#import "CNLiveUserInfo.h"
#import "CNLiveUserSystemTools.h"
#import "CNLiveUserManager.h"
#import "CNLiveUploadIcon.h"
@implementation CNLiveUserSystemCenter
+ (void)setAppId:(NSString *)appId appKey:(NSString *)appKey appSecret:(NSString *)appSecret
{
[CNLiveUserManager manager].appId = appId;
[CNLiveUserManager manager].appKey = appKey;
[CNLiveUserManager manager].appSecret = appSecret;
[[CNLiveUserManager manager] addObserver];
}
/**
* 注册
*/
+ (void)registerWithUserName:(NSString *)userName password:(NSString *)password verificationCode:(NSString *)verificationCode invitationCode:(NSString *)invitationCode frmId:(NSString *)frmId success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
CNLiveRegister *userRegister = [[CNLiveRegister alloc] init];
[userRegister registerWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey userName:userName password:password verificationCode:verificationCode invitationCode:invitationCode frmId:frmId success:success failure:failure];
}
/**
* 第三方登录
*/
+ (void)thirdPartyLoginWithThirdPartyPlatType:(NSString *)plat thirdPartyId:(NSString *)thirdPartyId nickName:(NSString *)nickName gender:(NSString *)gender location:(NSString *)location faceUrl:(NSString *)faceUrl frmId:(NSString *)frmId success:(void (^)(id result))success failure:(void (^)(NSError *))failure
{
CNLiveLogin *thirdLogin = [[CNLiveLogin alloc] init];
[thirdLogin thirdPartyLoginWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey thirdPartyPlatType:plat thirdPartyId:thirdPartyId nickName:nickName gender:gender location:location faceUrl:faceUrl frmId:frmId success:success failure:failure];
}
/**
* 快捷登录
*/
+ (void)shortcutLoginWithUserName:(NSString *)userName verificationCode:(NSString *)verificationCode frmId:(NSString *)frmId success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
CNLiveLogin *shortcutLogin = [[CNLiveLogin alloc] init];
[shortcutLogin shortcutLoginWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey userName:userName verificationCode:verificationCode frmId:frmId success:success failure:failure];
}
/**
* 登录
*/
+ (void)loginWithUserName:(NSString *)userName password:(NSString *)password frmId:(NSString *)frmId success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
CNLiveLogin *login = [[CNLiveLogin alloc] init];
[login loginWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey userName:userName password:password frmId:frmId success:success failure:failure];
}
/**
* 发送验证码
*/
+ (void)verificationCodeType:(VerificationCodeType)type mobile:(NSString *)mobile success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
CNLiveVerificationCode *verification = [[CNLiveVerificationCode alloc] init];
[verification getVerificationCodeWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey type:type mobile:mobile success:success failure:failure];
}
/**
* 更新用户附加信息
*/
+ (void)updateOtherInfoWithUid:(NSString *)uid extInfo:(NSString *)extInfo success:(void (^)(id result))success failure:(void (^)(NSError *))failure
{
CNLiveUserInfo *updateOtherInfo = [[CNLiveUserInfo alloc] init];
[updateOtherInfo updateOtherInfoWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey uid:uid extInfo:extInfo token:[[self class] getToken] success:success failure:failure];
}
/**
* 修改用户单项信息
*/
+ (void)modifyUserInfoType:(UserInfoType)type uid:(NSString *)uid modifyInfo:(NSString *)info success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
CNLiveUserInfo *updateUserInfo = [[CNLiveUserInfo alloc] init];
[updateUserInfo modifyUserInfoWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey type:type uid:uid modifyInfo:info token:[[self class] getToken] success:success failure:failure];
}
/**
* 更新手机号
*/
+ (void)updateMobileWithUid:(NSString *)uid mobile:(NSString *)mobile verificationCode:(NSString *)verificationCode success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
CNLiveUserInfo *updateMobile = [[CNLiveUserInfo alloc] init];
[updateMobile updateMobileWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey uid:uid mobile:mobile verificationCode:verificationCode token:[[self class] getToken] success:success failure:failure];
}
/**
* 修改密码
*/
+ (void)changePasswordWithMobile:(NSString *)mobile verificationCode:(NSString *)verificationCode newPassword:(NSString *)newPassword success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
CNLiveUserInfo *password = [[CNLiveUserInfo alloc] init];
[password changePasswordWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey mobile:mobile verificationCode:verificationCode newPassword:newPassword success:success failure:failure];
}
/**
* 上传头像
*/
+ (void)uploadIconWithUid:(NSString *)uid icon:(UIImage *)icon success:(void (^)(id))success failure:(void (^)(NSError *))failure
{
CNLiveUploadIcon *uplodIcon = [[CNLiveUploadIcon alloc] init];
[uplodIcon uploadIconWithAppId:[CNLiveUserManager manager].appId uid:uid icon:icon token:[[self class] getToken] secret:[CNLiveUserManager manager].appSecret success:success failure:failure];
}
/**
* 查询用户信息
*/
+ (void)queryUserInfoWithUid:(NSString *)uid srcUid:(NSString *)srcUid success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
CNLiveUserInfo *userInfo = [[CNLiveUserInfo alloc] init];
[userInfo queryUserInfoWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey uid:uid srcUid:srcUid token:[[self class] getToken] success:success failure:failure];
}
/**
* 用户反馈
*/
+ (void)feedbackWithContentId:(NSString *)contentId message:(NSString *)message success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
CNLiveFeedback *feedback = [[CNLiveFeedback alloc] init];
[feedback feedbackWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey contentId:contentId message:message success:success failure:failure];
}
#pragma mark - token
+ (NSString *)getToken
{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
if ([userDefaults objectForKey:@"CNLiveAuthToken"]) {
return [userDefaults objectForKey:@"CNLiveAuthToken"];
}
return @"";
}
@end