SDKAppID
.LogLevelEnum
.initSDK
to initialize the SDK.SDKAppID
.
SDKAppID
is the unique ID that the IM service uses to identify a customer account. We recommend you apply for a new SDKAppID
for every independent app to automatically isolate messages between SDKAppIDs
.
You can view all SDKAppIDs
in the IM console or click Create Application to create an SDKAppID
.
LogLevelEnum
(Dart) 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 of the DEBUG, INFO, WARNING, and ERROR levels (default log levels) are output. |
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/tencenet/imsdklogs/<App package name>
directory by default for versions earlier than 4.8.50 and in the /sdcard/Android/data/<Package name>/files/log/tencent/imsdk
directory for version 4.8.50 or later.python decode_mars_nocrypt_log_file.py imsdk_yyyyMMdd.xlog
V2TimSDKListener
.
We recommend you pass in V2TimSDKListener
(Dart) 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 are already logged in 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 the newly issued UserSig
to log in again. If you continue to use the expired UserSig
, the IM SDK will enter an infinite login loop.// 1. Get the `SDKAppID` from the IM console.int sdkAppID = 0;// 2. Add the `V2TimSDKListener` event listener. `sdkListener` is the implementation class of `V2TimSDKListener`.V2TimSDKListener sdkListener = V2TimSDKListener(onConnectFailed: (int code, String error) {// Connection failure callback function// `code`: Error code// `error`: Error message},onConnectSuccess: () {// The SDK is successfully connected to the CVM instance},onConnecting: () {// The SDK is connecting to the CVM instance},onKickedOffline: () {// The current user is kicked offline: the SDK notifies the user on the UI, and the user can choose to call the login() function of V2TIMManager to log in again.},onSelfInfoUpdated: (V2TimUserFullInfo info) {// The profile of the current user was updated// `info`: information of the login user},onUserSigExpired: () {// The ticket expires when the user is online: the user needs to generate a new userSig and call the login() function of V2TIMManager to log in again.},onUserStatusChanged: (List<V2TimUserStatus> userStatusList) {// User status change notification// `userStatusList`: list of users whose status changes// Notification receiving: This callback will be triggered if a subscribed user status (including online status and custom status) changes.// This callback will be triggered when a friend's status changes after notifications of friends' statuses are enabled in the IM console, even if the status has not been subscribed to.// This callback will be sent to all the devices when an account is logged in on them and the custom status is changed on one of them.},);// 3. Initialize the SDKV2TimValueCallback<bool> initSDKRes =await TencentImSDKPlugin.v2TIMManager.initSDK(sdkAppID: sdkAppID, // SDKAppIDloglevel: LogLevelEnum.V2TIM_LOG_ALL, // Log registration levellistener: sdkListener, // Event listener);if (initSDKRes.code == 0) {// Initialized successfully}
// Uninitialize the SDKTencentImSDKPlugin.v2TIMManager.unInitSDK();
Was this page helpful?