Last Updated on : 2023-03-09 08:17:39
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.
TuyaHomeSdk.getUserInstance().loginOrRegisterWithUid(String countryCode, String uid, String passwd, ILoginCallback callback);
// Allows users to create a default home.
TuyaHomeSdk.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.
TuyaHomeSdk.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