更新时间:2023-05-31 06:22:23下载pdf
智慧居住 iOS App SDK 提供邮箱地址验证码登录能力。
该接口中,SDK 不支持中国大陆地区的应用服务。因此,涉及到国家码的参数请勿设置 86 国家码。
接口说明
- (void)sendVerifyCodeByRegisterEmail:(NSString *)countryCode
email:(NSString *)email
success:(nullable TYSuccessHandler)success
failure:(nullable TYFailureError)failure;
参数说明
参数 | 说明 |
---|---|
countryCode | 国家码,例如 1 |
邮箱 | |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
[[TuyaSmartUser sharedInstance] sendVerifyCodeByRegisterEmail:@"your_country_code" email:@"your_email" success:^{
NSLog(@"sendVerifyCode success");
} failure:^(NSError *error) {
NSLog(@"sendVerifyCode failure: %@", error);
}];
Swift:
TuyaSmartUser.sharedInstance()?.sendVerifyCode(byRegisterEmail: "your_country_code", email: "your_email", success: {
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:(TYSuccessBOOL)success
failure:(TYFailureError)failure;
参数说明
参数 | 说明 |
---|---|
userName | 邮箱地址 |
region | 区域,默认填 nil |
countryCode | 国家码,例如 1 |
code | 经过验证码发送接口,收到的验证码 |
type | 验证码类型。取值:
|
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
[[TuyaSmartUser 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:
TuyaSmartUser.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 TYSuccessHandler)success
failure:(nullable TYFailureError)failure;
参数说明
参数 | 说明 |
---|---|
countryCode | 国家码,例如 1 |
邮箱 | |
password | 密码 |
code | 经过验证码发送接口,收到的验证码 |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
[[TuyaSmartUser 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:
TuyaSmartUser.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 TYSuccessHandler)success
failure:(nullable TYFailureError)failure;
参数说明
参数 | 说明 |
---|---|
countryCode | 国家码,例如 1 |
邮箱账号 | |
password | 密码 |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
[[TuyaSmartUser sharedInstance] loginByEmail:@"your_country_code" email:@"your_email" password:@"your_password" success:^{
NSLog(@"login success");
} failure:^(NSError *error) {
NSLog(@"login failure: %@", error);
}];
Swift:
TuyaSmartUser.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)resetPasswordByEmail:(NSString *)countryCode
email:(NSString *)email
newPassword:(NSString *)newPassword
code:(NSString *)code
success:(nullable TYSuccessHandler)success
failure:(nullable TYFailureError)failure;
参数说明
参数 | 说明 |
---|---|
countryCode | 国家码,例如 1 |
邮箱 | |
newPassword | 新密码 |
code | 经过验证码发送接口,收到的验证码 |
success | 接口发送成功回调 |
failure | 接口发送失败回调,error 表示失败原因 |
示例代码
Objc:
- (void)resetPasswordByEmail {
[TuyaSmartUser 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() {
TuyaSmartUser.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)")
}
})
}
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈