SDKAppID
.LogLevelEnum
.initSDK
to initialize the SDK.SDKAppID
.
The SDKAppID
uniquely identifies a Tencent Cloud IM account. We recommend you apply for a new SDKAppID
for each application. Messages are naturally isolated and cannot communicate between different SDKAppID
values.
In the IM console, you can view all your SDKAppID
values, and you can click Create Application to create an SDKAppID
.
LogLevelEnum
object, which is used to set the SDK log level.Log Level | Log Output |
LogLevelEnum.V2TIM_LOG_NONE | No log is output. |
LogLevelEnum.V2TIM_LOG_DEBUG | Logs at the DEBUG, INFO, WARNING, and ERROR levels are output (default log levels). |
LogLevelEnum.V2TIM_LOG_INFO | Logs at the INFO, WARNING, and ERROR levels are output. |
LogLevelEnum.V2TIM_LOG_WARN | Logs at the WARNING and ERROR levels are output. |
LogLevelEnum.V2TIM_LOG_ERROR | Logs at the ERROR level are output. |
/sdcard/tencent/imsdklogs/application package name
directory for versions earlier than v4.8.50 and in the /sdcard/Android/data/package name/files/log/tencent/imsdk
directory for v4.8.50 or later.python decode_mars_nocrypt_log_file.py imsdk_yyyyMMdd.xlog
V2TimSDKListener
.
We recommend you pass in V2TimSDKListener
(Details) when calling initSDK
to add the SDK event listener and perform logic processing in the callback.V2TimSDKListener
callbacks are as follows:Event Callback | Event Description | Recommended Operation |
onConnecting | The SDK is connecting to the CVM instance. | Display the "connecting" status on the UI. |
onConnectSuccess | The SDK is successfully connected to the CVM instance. | - |
onConnectFailed | The SDK failed to connect to the CVM instance. | Notify the user that the network connection is currently unavailable. |
onKickedOffline | The current user is kicked offline. | Display the "You have already logged in to the current account on another device. Are you sure you want to log in again?" message on the UI. |
onUserSigExpired | The login ticket expired. | Log in with a new UserSig . |
onSelfInfoUpdated | The current user's profile is updated. | Update the profile photo and nickname on the UI. |
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.import { TencentImSDKPlugin, LogLevelEnum } from 'react-native-tim-js';// 1. Get the `SDKAppID` from the IM console.const sdkAppID = 0;// 2. Add the `V2TimSDKListener` event listener.const sdkListener = {onConnectFailed: (code, error) {},onConnectSuccess: () {},onConnecting: () {},onKickedOffline: () {},onSelfInfoUpdated: (V2TimUserFullInfo info) {},onUserSigExpired: () {},};// 3. Perform the initialization and register the event.TencentImSDKPlugin.v2TIMManager.initSDK(sdkAppID: sdkAppID,loglevel: LogLevelEnum.V2TIM_LOG_ALL,listener: sdkListener,);
import { TencentImSDKPlugin } from "react-native-tim-js";// Uninitialize the SDKTencentImSDKPlugin.v2TIMManager.unInitSDK();
Was this page helpful?