Last Updated on : 2024-05-31 08:35:28download
Compliance issues and risks might be caused if users are allowed to upload a custom avatar. To protect you from these potential problems, this API method is deprecated. Adjust your app features accordingly and avoid using this API method.
Parameter description
Parameters | Description |
---|---|
headIcon | The image of the avatar. |
success | The success callback. |
failure | The failure callback. An error message is returned to indicate the cause. |
Example
Objective-C:
- (void)updateHeadIcon:(UIImage *)headIcon {
[[ThingSmartUser sharedInstance] updateHeadIcon:headIcon success:^{
NSLog(@"update head icon success");
} failure:^(NSError *error) {
NSLog(@"update head icon failure: %@", error);
}];
}
Swift:
func updateHeadIcon(_ headIcon: UIImage) {
ThingSmartUser.sharedInstance()?.updateHeadIcon(headIcon, success: {
print("update head icon success")
}, failure: { (error) in
if let e = error {
print("update head icon failure: \(e)")
}
})
}
API description
- (void)updateTempUnitWithTempUnit:(NSInteger)tempUnit
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
Parameter description
Parameters | Description |
---|---|
tempUnit | The unit of temperature.
|
success | The success callback. |
failure | The failure callback. An error message is returned to indicate the cause. |
Example
Objective-C:
- (void)updateTempUnitWithTempUnit:(NSInteger)tempUnit {
[[ThingSmartUser sharedInstance] updateTempUnitWithTempUnit:tempUnit success:^{
NSLog(@"update temp unit success");
} failure:^(NSError *error) {
NSLog(@"update temp unit failure: %@", error);
}];
}
Swift:
func updateTempUnit(withTempUnit tempUnit: Int) {
ThingSmartUser.sharedInstance().updateTempUnit(withTempUnit: tempUnit, success: {
print("update temp unit success")
}, failure: { error in
if let error = error {
print("update temp unit failure: \(error)")
}
})
}
API description
- (void)updateNickname:(NSString *)nickName
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
Parameter description
Parameters | Description |
---|---|
nickName | The nickname. |
success | The success callback. |
failure | The failure callback. An error message is returned to indicate the cause. |
Example
Objective-C:
- (void)modifyNickname:(NSString *)nickname {
[[ThingSmartUser sharedInstance] updateNickname:nickname success:^{
NSLog(@"updateNickname success");
} failure:^(NSError *error) {
NSLog(@"updateNickname failure: %@", error);
}];
}
Swift:
func modifyNickname(_ nickName: String) {
ThingSmartUser.sharedInstance()?.updateNickname(nickName, success: {
print("updateNickname success")
}, failure: { (error) in
if let e = error {
print("updateNickname failure: \(e)")
}
})
}
API description
- (void)updateTimeZoneWithTimeZoneId:(NSString *)timeZoneId
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
Parameter description
Parameters | Description |
---|---|
timeZoneId | The time zone ID. Example: Asia/Shanghai . |
success | The success callback. |
failure | The failure callback. An error message is returned to indicate the cause. |
Example
Objective-C:
- (void)updateTimeZoneId:(NSString *)timeZoneId {
[[ThingSmartUser sharedInstance] updateTimeZoneWithTimeZoneId:timeZoneId success:^{
NSLog(@"update timeZoneId success");
} failure:^(NSError *error) {
NSLog(@"update timeZoneId failure: %@", error);
}];
}
Swift:
func updateTimeZoneId(_ timeZoneId: String) {
ThingSmartUser.sharedInstance()?.updateTimeZone(withTimeZoneId: timeZoneId, success: {
print("update timeZoneId success")
}, failure: { (error) in
if let e = error {
print("update timeZoneId failure: \(e)")
}
})
}
API description
- (void)updateLatitude:(double)latitude longitude:(double)longitude;
Parameter description
Parameters | Description |
---|---|
latitude | The latitude of the user. |
longitude | The longitude of the user. |
Example
Objective-C:
- (void)updateLocation {
double latitude = 30.000;
double longitude = 120.000;
[[ThingSmartSDK sharedInstance] updateLatitude:latitude longitude:longitude];
}
Swift:
func updateLocation() {
ThingSmartSDK.sharedInstance()?.updateLatitude(latitude, longitude: longitude);
}
API description
/// Change to bind a mobile phone number or an email address.
/// @param account A mobile phone number or an email address.
/// @param countryCode The country code.
/// @param code The verification code.
/// @param success Called when the task is finished.
/// @param failure Called when the task is interrupted by an error.
- (void)changBindAccount:(NSString *)account
countryCode:(NSString *)countryCode
code:(NSString *)code
success:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
Parameter description
Parameters | Description |
---|---|
account | The account, which can be a phone number or email address. |
countryCode | The country code. |
code | The verification code. |
success | The success callback. |
failure | The failure callback. An error message is returned to indicate the cause. |
Example
Objective-C:
[[ThingSmartSDK sharedInstance] changBindAccount:@"example@example.com"
countryCode:@"001"
code:@"123456"
success:^(id result) {
NSLog(@"Success: %@", result);
} failure:^(NSError *error) {
NSLog(@"Error: %@", error.localizedDescription);
}];
Swift:
ThingSmartSDK.sharedInstance().changBindAccount("example@example.com",
countryCode: "001",
code: "123456",
success: { result in
print("Success: \(result)")
}, failure: { error in
print("Error: \(error.localizedDescription)")
})
API description
- (void)loginOut:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
Parameter description
Parameters | Description |
---|---|
success | The success callback. |
failure | The failure callback. An error message is returned to indicate the cause. |
Example
Objective-C:
- (void)loginOut {
[ThingSmartUser sharedInstance] loginOut:^{
NSLog(@"logOut success");
} failure:^(NSError *error) {
NSLog(@"logOut failure: %@", error);
}];
}
Swift:
func loginOut() {
ThingSmartUser.sharedInstance()?.loginOut({
print("logOut success")
}, failure: { (error) in
if let e = error {
print("logOut failure: \(e)")
}
})
}
API description
Deletes a user account. During the week following this delete operation, if the user is logged in again, the delete request is canceled. If not, the user is permanently disabled and all its information is deleted after this week.
- (void)cancelAccount:(nullable ThingSuccessHandler)success
failure:(nullable ThingFailureError)failure;
Parameter description
Parameters | Description |
---|---|
success | The success callback. |
failure | The failure callback. An error message is returned to indicate the cause. |
Example
Objective-C:
- (void)cancelAccount {
[ThingSmartUser sharedInstance] cancelAccount:^{
NSLog(@"cancel account success");
} failure:^(NSError *error) {
NSLog(@"cancel account failure: %@", error);
}];
}
Swift:
func cancelAccount() {
ThingSmartUser.sharedInstance()?.cancelAccount({
print("cancel account success")
}, failure: { (error) in
if let e = error {
print("cancel account failure: \(e)")
}
})
}
If users reset the password or have not logged in for a long time, an error message is returned to indicate session expiration. In this case, you must listen for the notifications of ThingSmartUserNotificationUserSessionInvalid
and navigate users to the login page.
When a session expires, SDKs earlier than v3.0 will receive multiple ThingSmartUserNotificationUserSessionInvalid
notifications, causing your callback to be invoked multiple times and resulting in issues. It is recommended to implement processing the notification only once by using boolean variables or time windows.
Objective-C:
- (void)loadNotification {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionInvalid) name:ThingSmartUserNotificationUserSessionInvalid object:nil];
}
- (void)sessionInvalid {
NSLog(@"sessionInvalid");
// Navigate to login page
MyLoginViewController *vc = [[MyLoginViewController alloc] init];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
}
Swift:
func loadNotification() {
NotificationCenter.default.addObserver(self, selector: #selector(sessionInvalid), name: NSNotification.Name(rawValue: "ThingSmartUserNotificationUserSessionInvalid"), object: nil)
}
@objc func sessionInvalid() {
print("sessionInvalid")
//Navigate to login page
let vc = MyLoginViewController()
window.rootViewController = vc
window.makeKeyAndVisible()
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback