更新时间:2023-04-17 08:31:21下载pdf
智能生活 App SDK 提供邮箱地址验证码登录能力。
接口说明
- (void)sendVerifyCodeWithUserName:(NSString *)userName
region:(NSString *_Nullable)region
countryCode:(NSString *)countryCode
type:(NSInteger)type
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
userName | 用户的邮箱地址或手机号码 |
region | 地区,可以通过 [ThingSmartUser regionListWithCountryCode:success:failure:] 或者 [ThingSmartUser getDefaultRegionWithCountryCode:] 查询 |
countryCode | 国家或地区码,例如 86 代表中国大陆地区 |
type | 验证码类型。取值:
|
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
[[ThingSmartUser sharedInstance] sendVerifyCodeWithUserName:@"your_email" region:@"your_region" countryCode:@"your_country_code" type:1 success:^{
NSLog(@"sendVerifyCode success");
} failure:^(NSError *error) {
NSLog(@"sendVerifyCode failure: %@", error);
}];
Swift:
ThingSmartUser.sharedInstance().sendVerifyCode(withUserName: "your_email", region: "your_region", countryCode: "your_country_code", type: 1) {
print("sendVerifyCode success")
} failure: { error in
if let e = error {
print("sendVerifyCode failure: \(e)")
}
}
接口说明
用于注册、登录、重设密码邮箱地址账号时,校验验证码。
- (void)checkCodeWithUserName:(NSString *)userName
region:(NSString *_Nullable)region
countryCode:(NSString *)countryCode
code:(NSString *)code
type:(NSInteger)type
success:(ThingSuccessBOOL)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
userName | 手机号码或邮箱地址 |
region | 区域,默认填 nil |
countryCode | 国家码,例如 86 |
code | 经过验证码发送接口,收到的验证码 |
type | 验证码类型。取值:
|
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
[[ThingSmartUser sharedInstance] checkCodeWithUserName:@"email_or_phone_number" region:@"region" countryCode:@"your_country_code" code:@"verify_code" type:1 success:^(BOOL result) {
if (result) {
NSLog(@"valid code!");
} else {
NSLog(@"invalid code!");
}
} failure:^(NSError *error) {
NSLog(@"check code failure: %@", error);
}];
Swift:
ThingSmartUser.sharedInstance()?.checkCode(withUserName: "email_or_phone_number", region: "region", countryCode: "your_country_code", code: "verify_code", type: type, success: { (result) in
if result {
print("valid code!")
} else {
print("invalid code!")
}
}, failure: { (error) in
if let error = error {
print("check code failure: \(error)")
}
})
使用邮箱地址注册账号,您需要先 获取验证码。
接口说明
- (void)registerByEmail:(NSString *)countryCode
email:(NSString *)email
password:(NSString *)password
code:(NSString *)code
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
countryCode | 国家码,例如 86 |
邮箱地址 | |
password | 密码 |
code | 经过验证码发送接口,收到的验证码 |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
[[ThingSmartUser sharedInstance] registerByEmail:@"your_country_code" email:@"your_email" password:@"your_password" code:@"verify_code" success:^{
NSLog(@"register success");
} failure:^(NSError *error) {
NSLog(@"register failure: %@", error);
}];
Swift:
ThingSmartUser.sharedInstance()?.register(byEmail: "your_country_code", email: "your_email", password: "your_password", code: "verify_code", success: {
print("register success")
}, failure: { (error) in
if let e = error {
print("register failure: \(e)")
}
})
接口说明
- (void)loginByEmail:(NSString *)countryCode
email:(NSString *)email
password:(NSString *)password
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
countryCode | 国家码,例如 86 |
邮箱地址 | |
password | 密码 |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
[[ThingSmartUser sharedInstance] loginByEmail:@"your_country_code" email:@"your_email" password:@"your_password" success:^{
NSLog(@"login success");
} failure:^(NSError *error) {
NSLog(@"login failure: %@", error);
}];
Swift:
ThingSmartUser.sharedInstance()?.login(byEmail: "your_country_code", email: "your_email", password: "your_password", success: {
print("login success")
}, failure: { (error) in
if let e = error {
print("login failure: \(e)")
}
})
使用邮箱登录,您需要先 获取验证码。
接口说明
- (void)loginWithEmail:(NSString *)email
countryCode:(NSString *)countryCode
code:(NSString *)code
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
邮箱 | |
countryCode | 国家码 |
code | 验证码 |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
[[ThingSmartUser sharedInstance] loginWithEmail:@"your_email" countryCode:@"your_country_code" code:@"your_code" success:^{
NSLog(@"sendVerifyCode success");
} failure:^(NSError *error) {
NSLog(@"sendVerifyCode failure: %@", error);
}];
Swift:
ThingSmartUser.sharedInstance().login(withEmail: "your_email", countryCode: "your_country_code", code: "your_code") {
print("login success")
} failure: { error in
if let e = error {
print("login failure: \(e)")
}
}
接口说明
当用户使用手机号码登录后,还可以绑定用户的邮箱账号。成功后,用户就可以同时使用邮箱登录账号。为手机号码账号绑定邮箱地址前,您需要先 获取验证码。
- (void)bindEmail:(NSString *)email
withCountryCode:(NSString *)countryCode
code:(NSString *)code
sId:(NSString *)sId
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
邮箱地址 | |
countryCode | 国家码,例如 86 |
code | 经过验证码发送接口,收到的验证码 |
sId | session Id |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
[[ThingSmartUser sharedInstance] sendBindingVerificationCodeWithEmail:userName
countryCode:countryCode
success:^{
// send success
} failure:^(NSError *error) {
NSLog(@"sendBindingVerificationCodeWithEmail failure: %@", error);
}
];
[[ThingSmartUser sharedInstance] bindEmail:account
withCountryCode:countryCode
code:code
sId:[ThingSmartUser sharedInstance].sid
success:^{
// bind successd
}];
} failure:^(NSError *error) {
NSLog(@"bind failure: %@", error);
}];
重置邮箱地址账户的密码前,您需要先 获取验证码。
接口说明
- (void)resetPasswordByEmail:(NSString *)countryCode
email:(NSString *)email
newPassword:(NSString *)newPassword
code:(NSString *)code
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
countryCode | 国家码,例如 86 |
邮箱地址 | |
newPassword | 新密码 |
code | 经过验证码发送接口,收到的验证码 |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
- (void)resetPasswordByEmail {
[[ThingSmartUser sharedInstance] resetPasswordByEmail:@"your_country_code" email:@"your_email" newPassword:@"your_password" code:@"verify_code" success:^{
NSLog(@"resetPasswordByEmail success");
} failure:^(NSError *error) {
NSLog(@"resetPasswordByEmail failure: %@", error);
}];
}
Swift:
func resetPasswordByEmail() {
ThingSmartUser.sharedInstance()?.resetPassword(byEmail: "your_country_code", email: "your_email", newPassword: "your_password", code: "verify_code", success: {
print("resetPasswordByEmail success")
}, failure: { (error) in
if let e = error {
print("resetPasswordByEmail failure: \(e)")
}
})
}
绑定手机号,包括获取绑定验证码接口和绑定手机号接口。
接口说明
- (void)sendBindVerifyCode:(NSString *)countryCode
phoneNumber:(NSString *)phoneNumber
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
countryCode | 手机号码所在的国家区号,例如 86 表示中国大陆地区 |
phoneNumber | 手机号码 |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
接口说明
- (void)mobileBinding:(NSString *)countryCode
phoneNumber:(NSString *)phoneNumber
code:(NSString *)code
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
countryCode | 手机号码所在的国家区号,例如 86 表示中国大陆地区 |
phoneNumber | 手机号码 |
code | 验证码 |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
//获取绑定验证码
[[ThingSmartUser sharedInstance] sendBindVerifyCode:@"yourVerifyCode" phoneNumber:@"yourPhoneNumber" success:^{
} failure:^(NSError *error) {
}];
//绑定手机号
[[ThingSmartUser sharedInstance] mobileBinding:@"yourCountryCode" phoneNumber:@"yourPhoneNumber" code:@"yourVerifyCode" success:^{
} failure:^(NSError *error) {
}];
Swift:
ThingSmartUser.sharedInstance().sendBindVerifyCode("yourCountryCode", phoneNumber: "yourPhoneNumber") {
print("login success")
} failure: { error in
if let e = error {
print("login failure: \(e)")
}
}
ThingSmartUser.sharedInstance().mobileBinding("yourCountryCode", phoneNumber: "yourPhoneNumber", code: "yourVerifyCode") {
print("login success")
} failure: { error in
if let e = error {
print("login failure: \(e)")
}
}
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈