initSDK

Introduction

init SDK

Step 1: Prepare an SDKAppID.

Step 2: Pet the LogLevelEnum.

Step 3: PSet the SDK event listener.

Step 4: Pall initSDK to initialize the SDK.

To obtain the script for decompression, click Decode Log 27 (for Python 2.7) or Decode Log 30 (for Python 3.0).

In the Windows or macOS console, you can decompress log files by running the following command. After decompression, the file names end with "xlog.log", and you can use the text editor to open these files.

python decode_mars_nocrypt_log_file.py imsdk_yyyyMMdd.xlog

If you receive the onUserSigExpired callback, the UserSig that you use for login has expired. In this case, you need to use a new UserSig to log in again. If you continue to use the expired UserSig, the IM SDK will be in an infinite login loop.

Parameter details

Parameter name Parameter type Required Description
sdkAppID number yes sdkAppID, the ID for the specific application, can get from IM Console.
loglevel LogLevelEnum yes Log Level, referring to this document.
listener V2TimSDKListener yes The listener.

Returned template

V2TimValueCallback<boolean>

{
    code : number
    desc : string
    data : boolean
}

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.
data boolean The result of the initialization.

Code example

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

const sdkAppID = 0;

const sdkListener: V2TimSDKListener = {
    onConnectFailed: (code, error) => {



    },
    onConnectSuccess: () => {

    },
    onConnecting: () => {

    },
    onKickedOffline: () => {

    },
    onSelfInfoUpdated: (info) => {


    },
    onUserSigExpired: () => {

    },
    onUserStatusChanged: (userStatusList) => {





    },
};

const initSDKRes = await TencentImSDKPlugin.v2TIMManager.initSDK(
    sdkAppID,
    LogLevelEnum.V2TIM_LOG_DEBUG,
    sdkListener
);
if (initSDKRes.code === 0) {

}

results matching ""

    No results matching ""