Last Updated on : 2024-10-15 09:40:43download
Login with a user ID (UID) is implemented with the API method that integrates with registration and login. It automatically enables login if an account is registered, or enables registration and login if the account is not registered.
You might often misunderstand that UID refers to the UID in the Tuya system. In fact, the UID should be the unique user identifier in your system. By using the UID, you can establish a connection between your own system database and Tuya’s database.
ThingHomeSdk.getUserInstance().loginOrRegisterWithUid(String countryCode, String uid, String passwd, ILoginCallback callback);
// Allows users to create a default home.
ThingHomeSdk.getUserInstance().loginOrRegisterWithUid(String countryCode, String uid, String passwd, boolean isCreateHome, IUidLoginCallback callback);
Parameter | Description |
---|---|
countryCode | The country code, such as 86 . |
uid | The UID of the user. |
passwd | The random identifier that matches the account ID. Only one identifier is assigned to each account ID. This identifier is not the user’s actual password. |
isCreateHome | Specifies whether to create a default home. |
callback | The callback. |
// Enables login with the UID.
ThingHomeSdk.getUserInstance().loginOrRegisterWithUid("86", "1234", "123456", new ILoginCallback() {
@Override
public void onSuccess(User user) {
Toast.makeText(mContext, "Logged in successfully. Username:" , 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