Last Updated on : 2024-05-27 03:48:51download
This topic describes user services, allowing you to access login information and log in or out of a user account.
IUser methods
Method | Description |
---|---|
getUserId(): String | The unique identifier of the user. |
getUserName(): String | The name of the user. |
getSpaceType(): Int | The space type
|
Example
IUser user = UserService.user();
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
projectCode | String | Yes | The project code. |
userName | String | Yes | The username. |
password | String | Yes | The password. |
callback | IndustryValueCallBack<IUser> | Yes | The callback. |
Example
UserService.loginWithParams("projectCode", "userName", "password", new IndustryValueCallBack<IUser>() {
@Override
public void onSuccess(IUser iUser) {
Toast.makeText(v.getContext(), "login success : " + s, Toast.LENGTH_SHORT).show();
}
@Override
public void onError(int i, String s) {
Toast.makeText(v.getContext(), "login fail : " + s, Toast.LENGTH_SHORT).show();
}
});
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
callBack | IndustryCallBack | Yes | The callback object for handling the logout result. |
Example
UserService.logout(new IndustryCallBack() {
@Override
public void onSuccess() {
Toast.makeText(v.getContext(), "logout success", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(int i, String s) {
Toast.makeText(v.getContext(), "logout fail", Toast.LENGTH_SHORT).show();
}
});
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
callback | IndustryValueCallBack |
Yes | The callback. |
Example
UserService.fetchUserInfo(new IndustryValueCallBack<UserInfo>() {
@Override
public void onSuccess(UserInfo userInfo) {
// Success. Process user information.
// ...
}
@Override
public void onError(int errorCode, String errorMessage) {
// Failure. Process error messages.
// ...
}
});
Example
boolean isLogin = UserService.isLogin();
if (isLogin) {
// The logic for login status.
}
After you register a listener for login session expiration, this callback will be triggered when the user changes their password or remains inactive for a period. A successful callback indicates that the login has expired and prompts the user to log in again.
Example
UserService.setLoginExpiredListener(new LoginExpiredListener() {
@Override
public void onLoginExpired() {
// The logic for login session expiration.
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback