Last Updated on : 2023-04-17 08:32:32download
API description
- (void)registerAnonymousWithCountryCode:(NSString *)countryCode
userName:(NSString *)userName
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
Parameters
Parameter | Type | Description |
---|---|---|
countryCode | NSString | The country code. For example, 86 means China and 1 means the USA. |
userName | NSString | The nickname used for anonymous login. For example, a device name can be used. |
success | ThingSuccessHandler | The success callback. |
failure | ThingFailureError | The failure callback. An error message is returned. |
Example
ObjC:
NSString *countryCode = @"1"; // The USA.
NSString *usename = [UIDevice currentDevice].name; // The device name.
[[ThingSmartUser sharedInstance] registerAnonymousWithCountryCode:countryCode
userName:usename
success:^{
NSLog(@"anonymouse success");
} failure:^(NSError *error) {
NSLog(@"anonymouse failure: %@", error);
}];
Swift:
let countryCode = "1" // The USA.
let usename = UIDevice.current.name // The device name.
ThingSmartUser.sharedInstance().registerAnonymous(withCountryCode: countryCode,
userName: usename,
success: {
print("anonymouse success")
}, failure: { error in
if let error = error {
print("anonymouse failure: \(error)")
}
})
API description
Logs out of an anonymous account. This type of account is deleted immediately after logout. Other types of accounts might be deleted seven days after delete requests are sent.
- (void)deleteAnonymousAccountWithSuccess:(ThingSuccessHandler)success
failure:(ThingFailureError)failure
Parameters
Parameter | Type | Description |
---|---|---|
success | ThingSuccessHandler | The success callback. |
failure | ThingFailureError | The failure callback. An error message is returned. |
Example
ObjC:
[[ThingSmartUser sharedInstance] deleteAnonymousAccountWithSuccess:^{
NSLog(@"anonymous logout success");
} failure:^(NSError *error) {
NSLog(@"anonymous logout failure: %@", error);
}];
Swift:
ThingSmartUser.sharedInstance().deleteAnonymousAccount(withSuccess: {
print("anonymous logout success")
}, failure: { error in
if let error = error {
print("anonymous logout failure: \(error)")
}
})
API description
Adds a mobile phone number or email address to an anonymous account to change it into a normal account. Perform the following steps:
- (void)usernameBindingWithCountryCode:(NSString *)countryCode
userName:(NSString *)userName
code:(NSString *)code
password:(NSString *)password
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
Parameters
Parameter | Type | Description |
---|---|---|
countryCode | NSString* | The country code. For example, 86 means China and 1 means the USA. |
userName | NSString* | The mobile phone number or email address to be bound with the account. |
code | NSString* | The verification code. |
password | NSString* | The password to be reset. |
success | ThingSuccessHandler | The success callback. |
failure | ThingFailureError | The failure callback. An error message is returned. |
Example
ObjC:
NSString *countryCode = @"1"; // The USA.
NSString *username = @"example@test.com"; // The email address or mobile phone number to be bound with the account.
NSString *code = @"verify code numbers"; // The verification code sent to the email address or mobile phone number.
NSString *password = @"account password"; // Resets the password of the account.
[[ThingSmartUser sharedInstance] usernameBindingWithCountryCode:countryCode
userName:username
code:code
password:password
success:^{
NSLog(@"username bind success");
} failure:^(NSError *error) {
NSLog(@"username bind failure:%@", error);
}];
Swift:
let countryCode = "1" // The USA.
let username = "example@test.com" // The email address or mobile phone number to be bound with the account.
let code = "verify code numbers" // The verification code sent to the email address or mobile phone number.
let password = "account password" // Resets the password of the account.
ThingSmartUser.sharedInstance().usernameBinding(withCountryCode: countryCode, userName: username, code: code, password: password, success: {
print("username bind success")
}, failure: { error in
if let error = error {
print("username bind failure:\(error)")
}
})
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback