login

Introduction

user login

You can login to IM SDK, referring to this document.

An account can be registered automatically, once this userID login the first time.

You are supposed to invoke this method in the following scene:

After the initialize of SDK and TUIKit finished.

Your ticket expires on login: The callback of the login API returns the ERR_USER_SIG_EXPIRED (6206) or ERR_SVR_ACCOUNT_USERSIG_EXPIRED (70001) error code. In this case, you need to generate a new userSig to log in again.

Your ticket expires when the user is online: You may receive the onUserSigExpired callback when users are online. In this case, you need to generate a new userSig to log in again.

A user is kicked offline: When a user is kicked offline, the IM SDK will notify you through the onKickedOffline callback. In this case, you can prompt the user and call login to log in again.

You don't need to call the this method in the following scenarios:

After the user's network is disconnected and then reconnected, you don't need to call the login function, as the IM SDK will automatically go online.

The login process is running.

After you call the IM SDK API and log in successfully, DAU calculation will start; therefore, call the login API as needed to avoid a high DAU.

You cannot log in to multiple IM SDK accounts of the same application at the same time; otherwise, only the last logged in account will be online.

Parameter details

Parameter name Parameter type Required Description
userID string yes Unique user ID: It can contain up to 32 bytes of letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-).
userSig string yes Login ticket: It is calculated by your business server to ensure security. For more information, see Generating UserSig.

Returned template

V2TimCallback

{
    code : number
    desc : string
}

Return value details

name type description
code number Request result: Error codes. 0 means success.
desc string The description of the error. It will be empty if success.

Code example

import { TencentImSDKPlugin } from 'react-native-tim-js';

const userID = 'your user id';
const userSig = 'userSig from your server';
const loginRes = await TencentImSDKPlugin.v2TIMManager.login(userID, userSig);
if (loginRes.code === 0) {

} else {

}

results matching ""

    No results matching ""