Copied!
Private Cloud
  • Application Development Services
    • Quick Start
    • API Gateway
      • API Request
        • Request Structure
        • Authorization Method
        • Sign Requests
        • Global Error Codes
      • Best Practice
        • Set Postman Environment and Call API Operations
      • API List
        • Basic API
          • Authorization Token Management
            • Refresh Token
            • Get a Token
        • IoT Core
          • Device Management
            • Query Devices in Space
            • Get Status Reporting Log
            • Get Update Progress
            • Query Device Details in Bulk
            • Delete Device
            • Get Update Information
            • Query Device Details
            • Confirm Start of Update
            • Get Device State
            • Get Operation Log
            • Modify Basic Properties
            • Freeze/Unfreeze Device
            • Transfer Device
            • Restore Factory Defaults
            • Query Pairing Result
          • Device Control
            • Send Property
            • Query Properties
            • Modify Properties
            • Set Desired Property
            • Query Desired Properties
            • Query Things Data Model
            • Device Control (Standard Instruction Set)
              • Get Status Set
              • Send Commands
              • Get Specifications and Properties of the Device
              • Get Instruction Set of the Device
              • Get Instruction Set of the Category
              • Get Status of a Single Device
              • Get Latest Status of Multiple Devices
          • Device Group
            • Create Group
            • Delete Group
            • Query Group
            • Rename Group
            • Get Group in Space
            • Add Device
            • Delete Devices
            • Get Device Group
            • Query Group Properties
            • Send Group Properties
            • Query Group Devices
    • Message Gateway
      • Preparations
      • Development Guide
        • Integrate with Message Service
        • Data Signature
        • Message Types
      • Best Practices
        • Get Push Messages by Pulsar (Java SDK)
        • Get Push Messages by Pulsar (Python SDK)
        • Get Push Messages by Pulsar (Go SDK)
        • Get Push Messages by Pulsar (Node.js SDK)
        • Get Push Messages by Pulsar (C# SDK)
  • App Development
    • Preparation
    • Developer Guide for iOS
      • Fast Integration with Cube App SDK for iOS
      • Upgrade Guide
      • Quick Start with Cube App SDK for iOS
      • iOS App: Implement User Account Features
      • User Account Management (iOS)
        • Register and Login with Phone Number
        • Register and Login with Email Address
        • Login with UID
        • Login with Third-Party Account
        • Register and Login with Anonymous Account
        • QR Code-Based Login Authorization
        • Manage User Accounts
      • Home Management
        • Home Information Management
        • Room Information Management
        • Member Information Management
      • Device Pairing (iOS)
        • Wi-Fi EZ Mode
        • AP Mode
        • Wired Mode
        • Sub-Device Pairing
        • NB-IoT Device Pairing
        • HomeKit Device Pairing
        • Pegasus Pairing
        • CPPLUS Link-Based Device Binding
        • Matter Devices
          • Prepare for Integration with Matter Device
          • Pair Matter Device
        • Pair with QR Code on Device
      • Bluetooth Devices
        • Bluetooth Mesh
        • CPPLUS Mesh
      • Device Management
        • Firmware Update
        • Query Reported DP Logs
        • Device Sharing
        • Backup Wi-Fi Networks
        • Offline Device Alerts
        • CPPLUS Link-Based Devices
        • Manage Matter Devices
      • Device Control
        • Multi-Control Linkage
        • Scheduled Tasks
        • Group Management
        • All Category Control Panel
        • Air Conditioning Category Control Panel
        • Switch Control Panel
        • Device DP Parser
      • Smart Scenes
        • Scene Recommendation
      • Common API Methods
      • Integrate with Push Notifications
      • Message Management
        • Configure Push Notifications
        • Message Capabilities
      • Configure Widget Project
      • Error Codes
      • FAQ
      • Extension SDK
        • IPC SDK
          • SDK Architecture
          • Fast Integration with IPC SDK for iOS
          • Quick Start with IPC SDK for iOS
          • IPCs
          • Device Pairing
          • IPC Control (iOS)
          • Live Video Streaming
          • Playback of Video Stored on SD Card
          • SD Card Management
          • Audio and Video Features
          • Low Power Doorbell
          • PTZ Control
          • Doorbell Call Service
          • Cloud Storage
          • Cloud Storage Debugging Tool
          • Detection Alerts
          • Encrypted Images
          • Timeline View
          • Offline Log
          • Migrate IPC UI BizBundles
          • P2P Capabilities
          • IPC SDK Automated Test Tool
          • IPC SDK Test Cases (Reference)
          • FAQ
          • Error Codes
        • Sweeper SDK
          • P2P Download from Robot Vacuums
          • Gyroscope and Visual Robot Vacuums
          • Laser Robot Vacuum
          • Voice Package Download
          • Error Codes
          • Sample Code
        • Smart Lock SDK
          • Wi-Fi Lock
          • Bluetooth Lock
          • Wi-Fi Lock Audio and Video Capability
          • Smart Lock Basic API
      • What is UI BizBundle SDK for iOS?
        • Preparation
        • Integrate with Framework
        • Home Management UI BizBundle
        • Device Pairing UI BizBundle
        • Scene UI BizBundle
        • Multi-Control Linkage UI BizBundle
        • Device Control UI BizBundle
        • OTA UI BizBundle
        • Group Management UI BizBundle
        • Device Details UI BizBundle
        • Panel Multilingual BizBundle
        • IPC UI BizBundles
        • Cloud Storage UI BizBundle
        • FAQ UI BizBundle
        • Message Center UI BizBundle
        • Voice Skills Account Linking UI BizBundle
        • Theme Color Configuration BizBundle
        • Sharing UI BizBundle
      • Changelog
    • Developer Guide for Android
      • Fast Integration with Cube App SDK for Android
      • Upgrade Guide
      • User Account Management
        • Register and Login with Phone Number
        • Register and Login with Email Address
        • Login with UID
        • Login with Third-Party Account
        • Register and Login with Anonymous Account
        • QR Code-Based Login Authorization
        • Manage User Accounts
      • Home Management
        • Home Information Management
        • Room Information Management
        • Member Information Management
      • Device Pairing (iOS)
        • Wi-Fi EZ Mode
        • AP Mode
        • Wired Mode
        • Pair with QR Code on Device
        • Pegasus Pairing
        • Sub-Device Pairing
        • NB-IoT Device Pairing
        • CPPLUS Link-Based Device Binding
        • Matter Devices
          • Prepare for Integration with Matter Device
          • Pair Matter Device
        • Pair with QR Code on Device
      • Bluetooth Devices
        • Bluetooth LE Devices
        • Bluetooth Mesh
        • CPPLUS Mesh
      • Device Management
        • Firmware Update
        • Query Reported DP Logs
        • Device Sharing
        • Backup Wi-Fi Networks
        • Notifications of Devices Getting Offline
        • CPPLUS Link-Based Devices
        • Manage Matter Devices
      • Device Control
        • Sub-Device Control Through Zigbee Gateway
        • Multi-Control Linkage
        • Scheduled Tasks
        • Group Management
        • Device DP Parser
      • Smart Scenes
        • Scene Recommendation
      • Common API Methods
      • Integrate with Push Notifications
        • Integrate with FCM Push
        • Integrate with Xiaomi Push Notifications
        • Integrate with Huawei Push Notifications
      • Message Management
        • Configure Push Notifications
        • Message Capabilities
      • Error Codes
      • FAQ
      • Extension SDK
        • IPC SDK
          • IPC SDK Architecture
          • Fast Integration with IPC SDK for Android
          • IPCs
          • Device Pairing
          • Live Video Streaming
          • SD Card-Stored Video Playback
          • SD Card Management
          • Audio and Video Features
          • Cloud Storage
          • Cloud Storage Debugging Tool
          • Alert List
          • Video Alerts
          • Low Power Doorbell
          • Encrypted Images
          • Timeline View
          • P2P Capabilities
          • IPC SDK Automated Test Tool
          • IPC SDK Test Cases (Reference)
          • Error Codes
          • SDK Log
          • Changelog
        • Sweeper SDK
          • P2P Download from Robot Vacuums
          • Gyroscope and Visual Robot Vacuums
          • Laser Robot Vacuum
          • Voice Package Download
          • Changelog
          • Error Codes
          • Sample Code
        • Smart Lock SDK
          • Wi-Fi Smart Lock
          • Bluetooth Smart Lock
          • Wi-Fi Smart Lock Audio and Video Capabilities
          • Zigbee Lock
          • Smart Lock Basic API
          • Changelog
      • What is UI BizBundle SDK for iOS?
        • Preparation
        • Integrate with Framework
        • Home Management UI BizBundle
        • Device Pairing UI BizBundle
        • Generic Pairing BizBundle
        • Device Control UI BizBundle
        • Multi-Control Linkage UI BizBundle
        • Scene UI BizBundle
        • Group Management UI BizBundle
        • Device Details UI BizBundle
        • OTA UI BizBundle
        • IPC UI BizBundles
        • Cloud Storage UI BizBundle
        • Message Center UI BizBundle
        • FAQ UI BizBundle
        • Maps Service UI BizBundle
        • Voice Skills Account Linking UI BizBundle
        • Panel Multilingual BizBundle
        • Theme Color Configuration BizBundle
        • Sharing UI BizBundle
        • FAQ
      • Changelog
  1. Home
  2. App Development
  3. I OS
  4. Manage User Accounts

Manage User Accounts

Last Updated on: 2024-05-31 14:05:28

Manage account information

Change user avatar
Note

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)")
        }
    })
}
Set temperature unit

API description

- (void)updateTempUnitWithTempUnit:(NSInteger)tempUnit
                           success:(nullable ThingSuccessHandler)success
                           failure:(nullable ThingFailureError)failure;

Parameter description

Parameters Description
tempUnit The unit of temperature.
  • 1: °C
  • 2: °F
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)")
        }
    })
}
Modify user nickname

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)")
        }
    })
}
Update user time zone

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)")
        }
    })
}
Update user location

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);
}
Update account-associated phone or email

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)")
                     })

Log out or switch between accounts

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)")
        }
    })
}

Deactivate or delete account

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)")
        }
    })
}

Process session expiration

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.

Note

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()
}
  • Prev Doc QR Code-Based Login Authorization
  • Next Doc Home Management
This page contains content