LoginStore
Introduction
LoginStore provides a complete set of login management APIs, including user login, logout, and personal information settings. Through this class, you can manage user login status and user profiles.Notice:
Use LoginStore.shared singleton object to access the
LoginStore instance.Note:
Login status updates are delivered through loginState publisher. Subscribe to it to receive real-time updates about login status.
Features
User Login: Supports login using SDK application ID, user ID and user signature.
User Logout: Supports user logout operation.
Personal Information Settings: Supports setting user nickname, avatar, gender and other personal information.
Subscribable Data
LoginState fields are described below:
Property | Type | Description |
loginStatus | Login status. | |
loginUserInfo | Logged-in user information. |
API List
Function | Description |
Singleton object. | |
Login event listener. | |
Login event listener. | |
Login. | |
Logout. | |
Set personal information. | |
Set offline push certificate IDs. |
Getting Instance
LoginStore.shared
Singleton object.
Events Handling
addLoginListener
Add login listener.
abstract fun addLoginListener(listener: LoginListener)
It is recommended to add the listener before calling login, so that you can receive login-related events in a timely manner.
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
listener | Login listener. |
removeLoginListener
Remove login listener.
abstract fun removeLoginListener(listener: LoginListener)
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
listener | Login listener. |
Login Operations
login
Login.
abstract fun login(context: Context,sdkAppID: Int,userID: String,userSig: String,completion: CompletionHandler? = null)
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
context | Context | Context. |
sdkAppID | Int | |
userID | String | User ID. The recommended length limit is 32 bytes, and only uppercase and lowercase English letters (a-zA-Z), digits (0-9), underscores, and hyphens are allowed. |
userSig | String | User signature. For the generation of userSig, please refer to the Secure authentication with userSig. |
completion | Completion callback. |
logout
Logout.
abstract fun logout(completion: CompletionHandler? = null)
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
completion | Completion callback. |
setSelfInfo
Set personal information.
abstract fun setSelfInfo(userProfile: UserProfile,completion: CompletionHandler? = null)
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
userProfile | User profile. | |
completion | Completion callback. |
Push Configuration
setCertificateID
Set offline push certificate IDs.
abstract fun setCertificateID(config: Map<String, String>)
Pass each vendor's push certificate configuration as a
Map<String, String>. The SDK will detect the current device brand, request the device token from the corresponding vendor and report it to the IM backend automatically. Can be called at any time; calling in Application.onCreate is recommended. If invoked before login, the SDK caches the configuration and starts push registration automatically once login succeeds. Certificate IDs are obtained from the IM Console after uploading push certificates. The map keys must follow the strings in the table below; unknown keys are ignored, and a channel is not enabled when its value is missing. Supported keys.Key | Description |
huaweiCertificateId | Huawei push certificate ID |
xiaomiCertificateId | Xiaomi push certificate ID |
xiaomiAppId | Xiaomi open platform AppId |
xiaomiAppKey | Xiaomi open platform AppKey |
oppoCertificateId | OPPO push certificate ID |
oppoAppKey | OPPO open platform AppKey |
oppoAppSecret | OPPO open platform AppSecret |
vivoCertificateId | vivo push certificate ID |
honorCertificateId | Honor push certificate ID |
meizuCertificateId | Meizu push certificate ID |
meizuAppId | Meizu open platform AppId |
meizuAppKey | Meizu open platform AppKey |
fcmCertificateId | FCM (Firebase) push certificate ID |
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
config | Map<String, String> | Vendor push certificate configuration. The keys are predefined strings (see the "Supported keys" table above); unknown keys are ignored, and a channel is not enabled when its value is missing. |
Data Structures
LoginStatus
Login status.
Enum Value | Description |
UNLOGIN | Not logged in. |
LOGINED | Logged in. |
AllowType
Friend verification type.
Enum Value | Value | Description |
ALLOW_ANY | 0 | Allow anyone. |
NEED_CONFIRM | 1 | Need confirmation. |
DENY_ANY | 2 | Deny anyone. |
Gender
Gender.
Enum Value | Value | Description |
UNKNOWN | 0 | Unknown. |
MALE | 1 | Male. |
FEMALE | 2 | Female. |
LoginListener
Login event.
Methods
Method | Description |
onKickedOffline | Current user kicked offline. |
onLoginExpired | Login ticket expired. |
UserProfile
User profile.
Property | Type | Description |
userID | String | User ID. |
nickname | String? | Nickname. |
avatarURL | String? | Avatar URL. |
selfSignature | String? | Personal signature. |
gender | Gender. | |
role | Int? | Role. This field has no business restrictions, so you can safely use any valid integer value. |
level | Int? | Level. This field has no business restrictions, so you can safely use any valid integer value. |
birthday | Long? | Birthday. This field has no business restrictions, so you can safely use any valid integer value. |
allowType | Friend verification type. | |
customInfo | Map<String, ByteArray>? | Custom information. |
LoginState
Login state.
Property | Type | Description |
loginStatus | Login status. | |
loginUserInfo | Logged-in user information. |
