Last Updated on : 2022-02-17 06:11:15download
Tuya IoT Platform supports the management of user account information, including account binding, user information modification, session expiration processing, account deletion, and more.
Two API methods can be called to bind an account with an email address. First, get the verification code, and then use the verification code to bind the email address.
Declaration
Returns the verification code to bind the email address.
void sendBindVerifyCodeWithEmail(@NonNull String countryCode, @NonNull String email, @NonNull IResultCallback callback);
Parameters
Param | Description |
---|---|
countryCode | Country code, for example: 86 |
Email address | |
callback | Callback |
Declaration
Binds an account with an email address.
void bindEmail(@NonNull String countryCode, @NonNull String email, @NonNull String code, @NonNull String sId, @NonNull IResultCallback callback);
Parameters
Param | Description |
---|---|
countryCode | Country code, for example: 86 |
code | Verification code |
sId | User sessionId |
callback | Callback |
Example
TuyaOSUser.getUserInstance().sendBindVerifyCodeWithEmail("86","123456@123.com", new IResultCallback(){
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
Toast.makeText(mContext, "sendBindVerifyCodeWithEmail success", Toast.LENGTH_SHORT).show();
}
});
TuyaOSUser.getUserInstance().bindEmail("86", "123456@123.com","123456", TuyaOSUser.getUserInstance().getUser().getSid(), new IResultCallback() {
@Override
public void onError(String code, String error) {
Toast.makeText(mContext, "bind fail", Toast.LENGTH_SHORT).show();
}
@Override
public void onSuccess() {
Toast.makeText(mContext, "bind success", Toast.LENGTH_SHORT).show();
}
});
&&
Declaration
Changes the nickname.
void reRickName (String name, final IReNickNameCallback callback);
Parameters
Parameters | Description |
---|---|
name | Nickname |
callback | Callback |
Example
TuyaOSUser.getUserInstance().reRickName (nickName,
new IReNickNameCallback () {
@Override
public void onSuccess () {
}
@Override
public void onError (String code, String error) {
}
});
Declaration
Updates the time zone of a user.
void updateTimeZone(String timezoneId, IResultCallback callback);
Parameters
Parameters | Description |
---|---|
timezoneId | timezone id |
callback | callback |
Example
TuyaOSUser.getUserInstance().updateTimeZone (
timezoneId,
new IResultCallback () {
@Override
public void onSuccess () {
}
@Override
public void onError (String code, String error) {
}
});
Declaration
Uploads a user-defined avatar.
void uploadUserAvatar(File file, IBooleanCallback callback)
Parameters
Parameters | Description |
---|---|
file | User avatar image file |
callback | Callback |
** Example **
TuyaOSUser.getUserInstance().uploadUserAvatar (
file,
new IBooleanCallback () {
@Override
public void onSuccess () {
}
@Override
public void onError (String code, String error) {
}
});
Declaration
Sets whether the temperature unit is Celsius or Fahrenheit.
void setTempUnit (TempUnitEnum unit, IResultCallback callback);
Parameters | Description |
---|---|
unit | Unit |
callback | Callback |
If necessary, the location information can be reported through the following interfaces:
TuyaSdk.setLatAndLong (lat, lon);
If user information is modified, for example, when the user’s avatar or nickname is changed, you must call an API method to keep the user information up to date. If the app is logged in from multiple devices at the same time, and one device has the user information modified, the modification is synchronized to the other device. You can call the synchronization API method to synchronize the latest user information when user information is viewed.
Description
Synchronizes user information.
void updateUserInfo(IResultCallback callback);
Parameters
Parameters | Description |
---|---|
callback | callback |
Example
TuyaOSUser.getUserInstance().updateUserInfo(new IResultCallback() {
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
User user = TuyaOSUser.getUserInstance().getUser();
}
});
&&
Account logout involves logout of an anonymous account and logout of other accounts.
Declaration
Users who log in anonymously can log out through this interface. Anonymous accounts will be logged out immediately.
void touristLogOut(final ILogoutCallback callback)
Parameters
Params | Type | Description |
---|---|---|
success | ILogoutCallback | Callback |
Example
TuyaOSUser.getUserInstance().touristLogOut(new ILogoutCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(String code, String error) {
}
});
TuyaOSUser.getUserInstance().logout(new ILogoutCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(String errorCode, String errorMsg) {
}
});
After the account logout API method is called, the account will be permanently deleted after one week following the call and all information about the account will be deleted. If the account is logged in to again within that week, and the deletion request will be canceled.
void cancelAccount (IResultCallback callback);
Example
TuyaOSUser.getUserInstance().cancelAccount (new IResultCallback () {
@Override
public void onError (String code, String error) {
}
@Override
public void onSuccess () {
}
});
For more information, see Login-free token of cloud development.
Description
Gets the ticket field through the third-party interface and calls the interface to get user information.
TuyaOSUser.getUserInstance().loginWithTicket(String ticket, ILoginCallback callback);
Parameters
Parameter | Description |
---|---|
ticket | Third-party app uses “ticket” to enable login based on the SDK |
Example
//ticket login
TuyaOSUser.getUserInstance().loginWithTicket("ticket", new ILoginCallback() {
@Override
public void onSuccess(User user) {
Toast.makeText(mContext, "Successfully logged in:" , Toast.LENGTH_SHORT).show();
}
@Override
public void onError(String code, String error) {
Toast.makeText(mContext, "code: " + code + "error:" + error, Toast.LENGTH_SHORT).show();
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback