### Callback JSON Parameter Example for Get Options (JSON) Source: https://im.sdk.qcloud.com/doc/zh-cn/TIMMessageManagerFunction_8h Provides example JSON structures for the callback parameter when retrieving global message receive options. These examples illustrate the different keys used to represent message receiving levels, start times (hour/minute/second or timestamp), and duration. ```json [ { "kTIMMsgAllRecvMsgOptLevel" : "kTIMRecvMsgOpt_Not_Notify", "kTIMMsgAllRecvMsgOptStartHour" : 12, "kTIMMsgAllRecvMsgOptStartMinute" : 0, "kTIMMsgAllRecvMsgOptStartSecond" : 0, "kTIMMsgAllRecvMsgOptStartTimeStamp" : 0, "kTIMMsgAllRecvMsgDuration" : 7200, } ] // Or [ { "kTIMMsgAllRecvMsgOptLevel" : "kTIMRecvMsgOpt_Not_Notify", "kTIMMsgAllRecvMsgOptStartHour" : 0, "kTIMMsgAllRecvMsgOptStartMinute" : 0, "kTIMMsgAllRecvMsgOptStartSecond" : 0, "kTIMMsgAllRecvMsgOptStartTimeStamp" : 123456, "kTIMMsgAllRecvMsgDuration" : 7200, } ] ``` -------------------------------- ### Initialization and Login APIs Source: https://im.sdk.qcloud.com/doc/zh-cn/md_introduction_HarmonyOS%E6%A6%82%E8%A7%88 APIs for initializing the SDK, logging in and out, managing listener callbacks, and retrieving SDK status and version information. ```APIDOC ## Initialization and Login APIs ### Description APIs for initializing the SDK, logging in and out, managing listener callbacks, and retrieving SDK status and version information. ### Methods - **initSDK** - **Description**: Initializes the SDK. - **Endpoint**: Not specified - **unInitSDK** - **Description**: Uninitializes the SDK. - **Endpoint**: Not specified - **addIMSDKListener** - **Description**: Adds an IM SDK event listener. - **Endpoint**: Not specified - **removeIMSDKListener** - **Description**: Removes an IM SDK event listener. - **Endpoint**: Not specified - **getVersion** - **Description**: Retrieves the current version of the SDK. - **Endpoint**: Not specified - **getServerTime** - **Description**: Fetches the current time from the server. - **Endpoint**: Not specified - **login** - **Description**: Logs the user into the IM service. - **Endpoint**: Not specified - **logout** - **Description**: Logs the user out of the IM service. - **Endpoint**: Not specified - **getLoginStatus** - **Description**: Retrieves the current login status of the user. - **Endpoint**: Not specified - **getLoginUser** - **Description**: Gets the UserID of the currently logged-in user. - **Endpoint**: Not specified ``` -------------------------------- ### IMSDK Initialization and Login APIs Source: https://im.sdk.qcloud.com/doc/zh-cn/md_introduction_CPP%E6%A6%82%E8%A7%88 APIs for initializing the SDK, managing listeners, and handling user login/logout. These are prerequisites for using IMSDK services. ```APIDOC ## IMSDK Initialization and Login APIs ### Description APIs for initializing the SDK, managing listeners, and handling user login/logout. These are prerequisites for using IMSDK services. ### API Reference - **InitSDK**: Initializes the SDK. - **UnInitSDK**: Uninitializes the SDK. - **AddSDKListener**: Adds an IM listener. - **RemoveSDKListener**: Removes an IM listener. - **GetVersion**: Gets the version number. - **GetServerTime**: Gets the current server time. - **Login**: Logs in the user. - **Logout**: Logs out the user. - **GetLoginStatus**: Gets the login status. - **GetLoginUser**: Gets the UserID of the currently logged-in user. ``` -------------------------------- ### Get Message Do Not Disturb Start Time (Minute) Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMReceiveMessageOptInfo Retrieves the minute component of the message do not disturb start time. This function is used in conjunction with getStartHour() and getStartSecond() to determine the precise start time. ```cpp int getStartMinute (); ``` -------------------------------- ### IM SDK Initialization API Source: https://im.sdk.qcloud.com/doc/zh-cn/md_introduction_C%E6%A6%82%E8%A7%88 Provides APIs for initializing, deinitializing, and configuring the IM SDK, as well as retrieving SDK version and server time. ```APIDOC ## IM SDK Initialization Related Interfaces Initializes and successfully logs in, which is a prerequisite for normal use of Tencent Cloud IM services. ### API - **TIMInit** - Description: IM SDK initialization - **TIMUninit** - Description: IM SDK deinitialization - **TIMGetSDKVersion** - Description: Get IM SDK version number - **TIMGetServerTime** - Description: Get current server time - **TIMSetConfig** - Description: Set additional user configurations ``` -------------------------------- ### Get Message Retrieval Parameters - Java Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMMessageListGetOption These Java methods retrieve the currently configured parameters for message retrieval. This includes getting the retrieval type, user ID, group ID, message count, the starting message, the starting message sequence, and the time range begin and period. ```java int getGetType () String getUserID () String getGroupID () int getCount () V2TIMMessage getLastMsg () long getLastMsgSeq () long getGetTimeBegin () long getGetTimePeriod () ``` -------------------------------- ### Get Message Do Not Disturb Start Time (Second) Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMReceiveMessageOptInfo Retrieves the second component of the message do not disturb start time. This allows for fine-grained control over message notification scheduling. ```cpp int getStartSecond (); ``` -------------------------------- ### IM SDK Initialization and Login Source: https://im.sdk.qcloud.com/doc/zh-cn/md_introduction_Android%E6%A6%82%E8%A7%88 APIs for initializing the IM SDK, managing listeners, and handling user login/logout. ```APIDOC ## IMSDK Initialization and Login This section covers the core APIs required to initialize the IM SDK and manage user authentication. ### API Reference * **initSDK** * Description: Initializes the SDK. * Method: POST (Assumed) * Endpoint: N/A * **unInitSDK** * Description: Uninitializes the SDK. * Method: POST (Assumed) * Endpoint: N/A * **addIMSDKListener** * Description: Adds a listener for IM SDK events. * Method: POST (Assumed) * Endpoint: N/A * **removeIMSDKListener** * Description: Removes an IM SDK listener. * Method: POST (Assumed) * Endpoint: N/A * **getVersion** * Description: Retrieves the current version of the SDK. * Method: GET (Assumed) * Endpoint: N/A * **getServerTime** * Description: Fetches the current server time. * Method: GET (Assumed) * Endpoint: N/A * **login** * Description: Logs the user into the IM service. * Method: POST (Assumed) * Endpoint: N/A * Parameters: * Request Body: * `userID` (string) - Required - The user ID for login. * `userSig` (string) - Required - The authentication signature for the user. * **logout** * Description: Logs the user out of the IM service. * Method: POST (Assumed) * Endpoint: N/A * **getLoginStatus** * Description: Gets the current login status of the user. * Method: GET (Assumed) * Endpoint: N/A * **getLoginUser** * Description: Retrieves the UserID of the currently logged-in user. * Method: GET (Assumed) * Endpoint: N/A ### Notes * Do not mix usage of new and old API versions. ``` -------------------------------- ### Get Message Do Not Disturb Start Time (Hour) Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMReceiveMessageOptInfo Retrieves the hour component of the message do not disturb start time. This is part of the settings for message notification management within the IM SDK. ```cpp int getStartHour (); ``` -------------------------------- ### V2TIMManager - Initialization and Basic Operations Source: https://im.sdk.qcloud.com/doc/zh-cn/classV2TIMManager This section covers the fundamental operations of the V2TIMManager, including initialization, deinitialization, getting the SDK version, server time, and managing login/logout. ```APIDOC ## POST /api/v2/initSDK ### Description Initializes the IMSDK with the provided application ID and configuration. ### Method POST ### Endpoint /api/v2/initSDK ### Parameters #### Request Body - **sdkAppID** (uint32) - Required - The application ID obtained from the console. - **config** (V2TIMSDKConfig) - Required - Configuration information for the SDK. ### Request Example ```json { "sdkAppID": 12345678, "config": { "logLevel": 1, "enableAPNS": true } } ``` ### Response #### Success Response (200) - **success** (bool) - Indicates if the initialization was successful. #### Response Example ```json { "success": true } ``` ## GET /api/v2/version ### Description Retrieves the current version of the IMSDK. ### Method GET ### Endpoint /api/v2/version ### Response #### Success Response (200) - **version** (string) - The current version string of the SDK. #### Response Example ```json { "version": "2.x.x" } ``` ## GET /api/v2/serverTime ### Description Gets the current server time. ### Method GET ### Endpoint /api/v2/serverTime ### Response #### Success Response (200) - **serverTime** (int64) - The current server time in Unix timestamp format. #### Response Example ```json { "serverTime": 1678886400 } ``` ## POST /api/v2/login ### Description Logs the user into the IMSDK service using their user ID and user signature. ### Method POST ### Endpoint /api/v2/login ### Parameters #### Request Body - **userID** (string) - Required - The unique identifier for the user. - **userSig** (string) - Required - The signature for user authentication. ### Request Example ```json { "userID": "user123", "userSig": "your_user_sig_here" } ``` ### Response #### Success Response (200) - **success** (bool) - Indicates if the login was successful. #### Response Example ```json { "success": true } ``` ## POST /api/v2/logout ### Description Logs the user out of the IMSDK service. ### Method POST ### Endpoint /api/v2/logout ### Response #### Success Response (200) - **success** (bool) - Indicates if the logout was successful. #### Response Example ```json { "success": true } ``` ## GET /api/v2/loginUser ### Description Retrieves the user ID of the currently logged-in user. ### Method GET ### Endpoint /api/v2/loginUser ### Response #### Success Response (200) - **userID** (string) - The user ID of the logged-in user. #### Response Example ```json { "userID": "user123" } ``` ## GET /api/v2/loginStatus ### Description Gets the current login status of the user. ### Method GET ### Endpoint /api/v2/loginStatus ### Response #### Success Response (200) - **status** (enum) - The current login status (e.g., LOGOUT, LOGINED, KICKED, UNLOGIN). #### Response Example ```json { "status": "LOGINED" } ``` ## POST /api/v2/unInitSDK ### Description Deinitializes the IMSDK, releasing all resources. ### Method POST ### Endpoint /api/v2/unInitSDK ### Response #### Success Response (200) - **success** (bool) - Indicates if the deinitialization was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### SDK Initialization and Management Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMManager APIs for initializing, configuring, and managing the IM SDK. ```APIDOC ## POST /sdk/init ### Description Initializes the IM SDK with the provided application ID and configuration. This method must be called before any other SDK method. ### Method POST ### Endpoint /sdk/init ### Parameters #### Request Body - **sdkAppID** (int) - Required - The application ID obtained from the console. - **config** (V2TIMSDKConfig) - Optional - Configuration settings for the SDK. - **listener** (V2TIMSDKListener) - Optional - A listener for SDK events. ### Request Example ```json { "sdkAppID": 12345678, "config": {}, "listener": {} } ``` ### Response #### Success Response (200) - **success** (boolean) - True if the initialization was successful, false otherwise. #### Response Example ```json { "success": true } ``` ``` ```APIDOC ## GET /sdk/version ### Description Retrieves the current version of the IM SDK. ### Method GET ### Endpoint /sdk/version ### Response #### Success Response (200) - **version** (String) - The current SDK version. #### Response Example ```json { "version": "2.0.0" } ``` ``` ```APIDOC ## GET /sdk/serverTime ### Description Fetches the current server time from the IM service. ### Method GET ### Endpoint /sdk/serverTime ### Response #### Success Response (200) - **serverTime** (long) - The current UTC timestamp in seconds. #### Response Example ```json { "serverTime": 1678886400 } ``` ``` ```APIDOC ## POST /sdk/removeListener ### Description Removes a previously added IM SDK listener. ### Method POST ### Endpoint /sdk/removeListener ### Parameters #### Request Body - **listener** (V2TIMSDKListener) - Required - The listener to remove. ### Response #### Success Response (200) - **success** (boolean) - True if the listener was removed successfully, false otherwise. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Get Message Do Not Disturb Start Timestamp Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMReceiveMessageOptInfo Retrieves the message do not disturb start time as a UTC timestamp. If this value is greater than 0, it can be used directly; otherwise, individual time components (hour, minute, second) should be used. ```cpp long getStartTimeStamp (); ``` -------------------------------- ### Get C2C History Message List Source: https://im.sdk.qcloud.com/doc/zh-cn/categoryV2TIMManager_07Message_08 Fetches the history message list for a one-on-one chat (C2C) conversation. Supports retrieving messages up to a specified count, starting from the latest or a given message. ```APIDOC ## POST /im_sdk/getC2CHistoryMessageList ### Description Fetches the history message list for a one-on-one chat (C2C) conversation. Allows specifying the number of messages to retrieve and an optional starting message for pagination. ### Method POST ### Endpoint /im_sdk/getC2CHistoryMessageList ### Parameters #### Request Body - **userID** (NSString *) - Required - The user ID of the other party in the C2C conversation. - **count** (int) - Required - The number of messages to retrieve. Recommended to be around 20. - **lastMsg** (V2TIMMessage *_Nullable) - Optional - The starting message for fetching history. If nil, fetches from the latest messages. - **succ** (V2TIMMessageListSucc) - Required - Callback for successful retrieval, providing the list of messages. - **fail** (_Nullable) - Optional - Callback for failure. ### Request Example ```json { "userID": "user123", "count": 20, "lastMsg": null, // Fetch from the latest messages "succ": (messages) => console.log(messages), "fail": (error) => console.error(error) } ``` ### Response #### Success Response (200) - **succ** (V2TIMMessageListSucc) - A callback that receives a list of V2TIMMessage objects. #### Response Example ```json // Callback receives an array of messages [ { "msgID": "msg_abc", "sender": "user123", "content": "Hello!" // ... other message properties } ] ``` ``` -------------------------------- ### IM SDK Initialization and Management Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMManager APIs for initializing, de-initializing, and managing the IM SDK, including adding/removing listeners and retrieving SDK version and server time. ```APIDOC ## V2TIMManager ### Description The main core class of the IM SDK, responsible for IM SDK initialization, login, message sending and receiving, group creation and exit, and other functions. ### Method `getInstance()` ### Endpoint N/A (Static method) ### Parameters None ### Response Example ```json { "manager": "V2TIMManager_instance" } ``` ## `initSDK` ### Description Initializes the IM SDK with the provided context, SDK App ID, and configuration. ### Method `initSDK(Context context, int sdkAppID, V2TIMSDKConfig config)` or `initSDK(Context context, int sdkAppID, V2TIMSDKConfig config, V2TIMSDKListener listener)` ### Endpoint N/A (Method of V2TIMManager) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **context** (Context) - Required - The application context. - **sdkAppID** (int) - Required - The application ID obtained from the console. - **config** (V2TIMSDKConfig) - Optional - Configuration information for the SDK. - **listener** (V2TIMSDKListener) - Optional - Listener for SDK events. ### Response #### Success Response (boolean) - **true**: Initialization successful. - **false**: Initialization failed (e.g., if context is null). ### Response Example ```json { "success": true } ``` ## `unInitSDK` ### Description De-initializes the IM SDK. ### Method `unInitSDK()` ### Endpoint N/A (Method of V2TIMManager) ### Parameters None ### Response Example ```json { "status": "success" } ``` ## `addIMSDKListener` ### Description Adds a listener for IM SDK events. ### Method `addIMSDKListener(V2TIMSDKListener listener)` ### Endpoint N/A (Method of V2TIMManager) ### Parameters - **listener** (V2TIMSDKListener) - Required - The listener object to add. ### Response Example ```json { "status": "listener_added" } ``` ## `removeIMSDKListener` ### Description Removes a previously added IM SDK listener. ### Method `removeIMSDKListener(V2TIMSDKListener listener)` ### Endpoint N/A (Method of V2TIMManager) ### Parameters - **listener** (V2TIMSDKListener) - Required - The listener object to remove. ### Response Example ```json { "status": "listener_removed" } ``` ## `getVersion` ### Description Retrieves the current version of the IM SDK. ### Method `getVersion()` ### Endpoint N/A (Method of V2TIMManager) ### Parameters None ### Response #### Success Response (String) - **version**: The SDK version string. ### Response Example ```json { "version": "2.x.x" } ``` ## `getServerTime` ### Description Retrieves the current server time. ### Method `getServerTime()` ### Endpoint N/A (Method of V2TIMManager) ### Parameters None ### Response #### Success Response (long) - **serverTime**: The current server time in milliseconds since the epoch. ### Response Example ```json { "serverTime": 1678886400000 } ``` ``` -------------------------------- ### Get Group History Message List Source: https://im.sdk.qcloud.com/doc/zh-cn/categoryV2TIMManager_07Message_08 Retrieves the history message list for a group conversation. Supports fetching a specified number of messages and starting from a particular message, with considerations for different group types. ```APIDOC ## POST /im_sdk/getGroupHistoryMessageList ### Description Fetches the history message list for a group conversation. Similar to C2C history retrieval, it allows specifying the message count and a starting message. Note that history retrieval for different group types (e.g., Meeting vs. AVChatRoom) may have different behaviors. ### Method POST ### Endpoint /im_sdk/getGroupHistoryMessageList ### Parameters #### Request Body - **groupID** (NSString *) - Required - The ID of the group conversation. - **count** (int) - Required - The number of messages to retrieve. Recommended to be around 20. - **lastMsg** (V2TIMMessage *_Nullable) - Optional - The starting message for fetching history. If nil, fetches from the latest messages. - **succ** (V2TIMMessageListSucc) - Required - Callback for successful retrieval, providing the list of messages. - **fail** (_Nullable) - Optional - Callback for failure. ### Request Example ```json { "groupID": "groupXYZ", "count": 20, "lastMsg": null, "succ": (messages) => console.log(messages), "fail": (error) => console.error(error) } ``` ### Response #### Success Response (200) - **succ** (V2TIMMessageListSucc) - A callback that receives a list of V2TIMMessage objects. #### Response Example ```json // Callback receives an array of messages [ { "msgID": "msg_def", "sender": "groupMember1", "content": "Group update!" // ... other message properties } ] ``` ``` -------------------------------- ### Initialize and Manage IMSDK Source: https://im.sdk.qcloud.com/doc/zh-cn/interfaceV2TIMManager Provides methods for initializing and uninitializing the IMSDK, adding and removing listeners, and retrieving SDK version and server time. It also includes methods for logging in and out users. ```Objective-C - (BOOL)initSDK:(id)config: - (void)addIMSDKListener:(id)listener: - (void)removeIMSDKListener:(id)listener: - (void)unInitSDK - (NSString *)getVersion - (uint64_t)getServerTime - (BOOL)initSDK:(id)config:listener:(id)listener: - (void)login:(NSString *)userID userSig:(NSString *)userSig succ:(V2TIMSucc)succ fail:(V2TIMFail)fail: - (void)logout:(V2TIMFail)fail: - (NSString *_Nullable)getLoginUser - (V2TIMLoginStatus)getLoginStatus ``` -------------------------------- ### C: IM SDK Initialization and Configuration Functions Source: https://im.sdk.qcloud.com/doc/zh-cn/TIMManagerFunction_8h This C code snippet includes essential IM SDK functions for initialization, configuration, and uninitialization. It covers setting up the SDK with an application ID and configuration, uninitializing the SDK, and retrieving the SDK version. These functions are crucial for starting and managing the IM SDK's lifecycle. ```c TIM_API int | TIMInit (uint64_t sdk_app_id, const char *json_sdk_config); TIM_API int | TIMUninit (void); TIM_API const char * | TIMGetSDKVersion (void); TIM_API int | TIMSetConfig (const char *json_config, TIMCommCallback cb, const void *user_data); ``` -------------------------------- ### Get C2C History Message List Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMMessageManager Fetches the historical messages for a one-on-one (C2C) chat. Allows specifying the number of messages to retrieve and the starting message for pagination. Note that behavior may vary based on login status and network connectivity. ```java void getC2CHistoryMessageList(String userID, int count, V2TIMMessage lastMsg, V2TIMValueCallback> callback); ``` -------------------------------- ### Get Specific Friend Profiles (C++) Source: https://im.sdk.qcloud.com/doc/zh-cn/TIMFriendshipManagerFunction_8h Fetches profile information for a specified list of friends. Results are delivered through a TIMCommCallback. An example demonstrates using a JSON array for friend IDs and handling the callback. ```cpp TIM_API int TIMFriendshipGetFriendsInfo(const char *friend_id_list, TIMCommCallback cb, const void *user_data); // Example Usage: json::Array json_array; json_array.push_back("98826"); TIMFriendshipGetFriendsInfo(json_array.toStyledString().c_str(), [](int32_t code, const char* desc, const char* json_param, const void* user_data) { printf("GetFriendsInfo code:%d|desc:%s|json_param %s\r\n", code, desc, json_param); }, nullptr); // Resulting JSON string for friend_id_list: // ["98826"] ``` -------------------------------- ### Event Callback Settings Source: https://im.sdk.qcloud.com/doc/zh-cn/md_introduction_C%E6%A6%82%E8%A7%88 APIs for setting up various event callbacks for network status, messages, and conversations. ```APIDOC ## Event Callback Setting APIs ### Initialization and Login Related Callback Setting APIs #### Description Set callbacks for initialization and login-related events. #### API Endpoints - **TIMSetNetworkStatusListenerCallback**: Set network status listener callback. - **TIMSetKickedOfflineCallback**: Set kicked offline callback. - **TIMSetUserSigExpiredCallback**: Set user signature expired callback. - **TIMSetLogCallback**: Set log callback. ### Message Related Callback Setting APIs #### Description Set callbacks for message-related events. #### API Endpoints - **TIMAddRecvNewMsgCallback**: Add a callback for receiving new messages. - **TIMRemoveRecvNewMsgCallback**: Remove a callback for receiving new messages. - **TIMSetMsgElemUploadProgressCallback**: Set callback for upload progress of message elements (files). - **TIMSetMsgReadedReceiptCallback**: Set callback for message read receipts. - **TIMSetMsgRevokeCallback**: Set callback for receiving revoked messages. - **TIMSetMsgUpdateCallback**: Set callback for message updates received when messages are modified on the cloud. - **TIMSetMsgExtensionsChangedCallback**: Set callback for message extension information changes. - **TIMSetMsgExtensionsDeletedCallback**: Set callback for message extension information deletions. - **TIMSetMsgReactionsChangedCallback**: Set callback for message reaction information updates. - **TIMSetMsgAllMessageReceiveOptionCallback**: Set callback for global message receiving options. ### Conversation Related Callback Setting APIs #### Description Set callbacks for conversation-related events. #### API Endpoints - **TIMSetConvEventCallback**: Set conversation event callback. - **TIMSetConvTotalUnreadMessageCountChangedCallback**: Set callback for changes in the total unread message count of conversations. - **TIMSetConvUnreadMessageCountChangedByFilterCallback**: Set callback for changes in the unread message count filtered by conversation. - **TIMSetConvConversationGroupCreatedCallback**: Set callback for conversation group creation. - **TIMSetConvConversationGroupDeletedCallback**: Set callback for conversation group deletion. - **TIMSetConvConversationGroupNameChangedCallback**: Set callback for conversation group name changes. - **TIMSetConvConversationsAddedToGroupCallback**: Set callback for conversations added to a group. - **TIMSetConvConversationsDeletedFromGroupCallback**: Set callback for conversations deleted from a group. ``` -------------------------------- ### Get Search Cursor (IM SDK) Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMMessageSearchResult Obtains the starting position for the next cloud-based search operation. This is essential for implementing pagination and continuous searching within the IM SDK, ensuring efficient retrieval of large datasets. ```c++ String getSearchCursor (); ``` -------------------------------- ### Create Community Source: https://im.sdk.qcloud.com/doc/zh-cn/categoryV2TIMManager_07Community_08 Creates a new community that supports topics. ```APIDOC ## POST /communities ### Description Creates a new community that supports topics. ### Method POST ### Endpoint `/communities` ### Parameters #### Request Body - **info** (V2TIMGroupInfo) - Required - Information about the community to be created. - **memberList** (Array) - Optional - A list of members to add to the community upon creation. ### Request Example ```json { "info": { "groupName": "My New Community", "groupType": "COMMUNITY" }, "memberList": [ { "userID": "user123", "role": "member" } ] } ``` ### Response #### Success Response (200) - **groupID** (string) - The ID of the newly created community. #### Response Example ```json { "groupID": "@TGS#2ABCDEFG" } ``` ``` -------------------------------- ### Get Group History Message List Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMMessageManager Fetches historical messages for a group chat. Similar to C2C history, it allows specifying the count and starting message. Limitations apply to certain group types (e.g., AVChatRoom) and message retrieval behavior depends on login status and network. ```java void getGroupHistoryMessageList(String groupID, int count, V2TIMMessage lastMsg, V2TIMValueCallback> callback); ``` -------------------------------- ### IM SDK Initialization and Login API Source: https://im.sdk.qcloud.com/doc/zh-cn/md_introduction_iOS%E6%A6%82%E8%A7%88 APIs for initializing the IM SDK, logging in, and managing user sessions. These are prerequisites for using Tencent Cloud IM services. ```APIDOC ## Initialization and Login APIs ### Description Provides core functionalities for initializing the IM SDK, logging in, and managing user sessions. Successful initialization and login are essential for utilizing Tencent Cloud IM services. ### API Reference | API | Description | |---|---| | `initSDK` | Initializes the IM SDK. | | `unInitSDK` | Deinitializes the IM SDK. | | `addIMSDKListener` | Adds a listener for IM SDK events. | | `removeIMSDKListener` | Removes a listener for IM SDK events. | | `getVersion` | Retrieves the current version of the IM SDK. | | `getServerTime` | Fetches the current server time. | | `login` | Logs in the current user to the IM service. | | `logout` | Logs out the current user from the IM service. | | `getLoginUser` | Retrieves the user ID of the currently logged-in user. | | `getLoginStatus` | Gets the current login status of the user. ``` -------------------------------- ### Get Topic Introduction in IMSDK C++ Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMTopicInfo Retrieves the introductory description of the chat topic. This method returns the introduction as a String. ```cpp String getIntroduction () ``` -------------------------------- ### Java: V2TIMElem - Get and Set Data Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMFaceElem Provides Java code examples for retrieving and setting custom data within a V2TIMElem object. These methods, `getData()` and `setData()`, are essential for handling custom message payloads, such as in V2TIMCustomElem. They are marked as `inline` for potential performance optimization. ```java byte[] data = v2TIMElem.getData(); // ... v2TIMElem.setData(data); ``` -------------------------------- ### Get Pending Friend Requests using TIMFriendshipGetPendencyList C++ Source: https://im.sdk.qcloud.com/doc/zh-cn/TIMFriendshipManagerFunction_8h Shows how to retrieve a list of pending friend requests using the TIMFriendshipGetPendencyList C++ API. It takes a JSON parameter to specify the type of pendency and a starting sequence number. A callback function is provided for handling the response. ```cpp json::Object json_get_pendency_list_param; json_get_pendency_list_param[kTIMFriendshipGetPendencyListParamType] = FriendPendencyTypeBoth; json_get_pendency_list_param[kTIMFriendshipGetPendencyListParamStartSeq] = 0; int ret = TIMFriendshipGetPendencyList(json_get_pendency_list_param.toStyledString().c_str(), [](int32_t code, const char* desc, const char* json_params, const void* user_data) { }, nullptr); ``` -------------------------------- ### Topic Creation Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMTopicInfo Create a new IM SDK topic with initial configuration details. ```APIDOC ## POST /group/{groupId}/topic ### Description Creates a new topic within a specified IM group. ### Method POST ### Endpoint `/group/{groupId}/topic` ### Parameters #### Path Parameters - **groupId** (String) - Required - The ID of the group to which the topic will be added. #### Request Body - **topicName** (String) - Required - The name for the new topic (max 150 bytes, UTF-8). - **topicFaceUrl** (String) - Optional - The URL for the topic's avatar (max 500 bytes, UTF-8). - **introduction** (String) - Optional - An introduction for the topic (max 400 bytes, UTF-8). - **notification** (String) - Optional - An announcement for the topic (max 400 bytes, UTF-8). - **topicType** (String) - Optional - The type of the topic (e.g., "Public", "Private"). Defaults to "Public". - **customString** (String) - Optional - A custom string associated with the topic. - **memberList** (List) - Optional - A list of members to initially add to the topic. - **topicAddOpt** (int) - Optional - The option for adding members to the topic (V2TIM_TOPIC_ADD_FORBID, V2TIM_TOPIC_ADD_AUTH, V2TIM_TOPIC_ADD_ANY). - **topicApproveOpt** (int) - Optional - The option for approving membership to the topic. - **memberMaxCount** (long) - Optional - The maximum number of members allowed in the topic. - **defaultPermissions** (long) - Optional - The default permissions for members in the topic. ### Request Example ```json { "topicName": "New Topic", "topicType": "Private", "introduction": "This is a private topic." } ``` ### Response #### Success Response (200) - **topicID** (String) - The unique identifier of the newly created topic. - **code** (int) - 0 indicates success. - **message** (String) - A message indicating the result of the operation. #### Response Example ```json { "topicID": "@TGS123@TOPIC_new1", "code": 0, "message": "Topic created successfully." } ``` ``` -------------------------------- ### Get Group Information Change Value Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMGroupChangeInfo The `getValue()` function returns the value associated with a group information change. The meaning of the value depends on the `type` returned by `getType()`. For example, if the type indicates a name change, the value will be the new group name. It returns a String representing the message content. ```java String value = v2TIMGroupChangeInfo.getValue(); ``` -------------------------------- ### IMSDK Configuration Parameters Source: https://im.sdk.qcloud.com/doc/zh-cn/md_c_api_TIMManagerJsonKey Defines the JSON keys for configuring the IMSDK, including file paths, thread IDs, device information, and proxy settings. ```APIDOC ## IMSDK Configuration Parameters ### Description This section details the JSON keys used for configuring the IMSDK. ### Parameters #### SDK Configuration (`SdKConfig`) - **kTIMSdkConfigConfigFilePath** (string) - Optional - Configuration file path. Default is "/". - **kTIMSdkConfigLogFilePath** (string) - Optional - Log file path. Default is "/". - **kTIMSdkConfigMainThreadID** (int64) - Optional - Main thread ID. - **kTIMSdkConfigMainLooperPointer** (int64) - Optional - Main thread Looper pointer. - **kTIMSdkConfigDisableCallbackOnMainThread** (bool) - Optional - Disables callbacks on the main thread (iOS/Mac only). #### Device and Brand Information - **kTIMSdkConfigDeviceType** (string) - Optional - Device type. - **kTIMSdkConfigBrandType** (int64) - Optional - Brand type. - **kTIMSdkConfigSystemVersion** (string) - Optional - System version. #### User Configuration (`UserConfig`) - **kTIMUserConfigIsDisableStorage** (bool) - Optional - Whether to disable local database. `true` to disable, `false` otherwise. Default is `false`. #### HTTP Proxy Configuration (`HttpProxyInfo`) - **kTIMHttpProxyInfoIp** (string) - Required - Proxy IP address. - **kTIMHttpProxyInfoPort** (int) - Required - Proxy port. - **kTIMHttpProxyInfoUserName** (string) - Optional - Authentication username. - **kTIMHttpProxyInfoPassword** (string) - Optional - Authentication password. #### SOCKS5 Proxy Configuration (`Socks5ProxyInfo`) - **kTIMSocks5ProxyInfoIp** (string) - Required - SOCKS5 proxy IP address. - **kTIMSocks5ProxyInfoPort** (int) - Required - SOCKS5 proxy port. - **kTIMSocks5ProxyInfoUserName** (string) - Optional - Authentication username. - **kTIMSocks5ProxyInfoPassword** (string) - Optional - Authentication password. #### PAC Proxy Configuration (`PACProxyInfo`) - **kTIMPACProxyInfoUserName** (string) - Optional - Authentication username. - **kTIMPACProxyInfoPassword** (string) - Optional - Authentication password. ### SetConfig (Update Configuration) - **kTIMSetConfigLogLevel** (uint TIMLogLevel) - Optional - Log level for file output. - **kTIMSetConfigCallbackLogLevel** (uint TIMLogLevel) - Optional - Log level for callbacks. - **kTIMSetConfigIsLogOutputConsole** (bool) - Optional - Whether to output logs to the console. Default is `true`. - **kTIMSetConfigUserConfig** (object UserConfig) - Optional - User configuration object. - **kTIMSetConfigUserDefineData** (string) - Optional - Custom data (up to 64 bytes) to be passed to the IM backend. - **kTIMSetConfigHttpProxyInfo** (object HttpProxyInfo) - Optional - Set HTTP proxy. Used for uploading/downloading files. IP cannot be empty and port cannot be 0. To cancel, set IP to empty string and port to 0. - **kTIMSetConfigSocks5ProxyInfo** (object Socks5ProxyInfo) - Optional - Set SOCKS5 proxy. Must be set before initialization. All SDK protocols will use this proxy. - **kTIMSetConfigPACProxyInfo** (object PACProxyInfo) - Optional - Set PAC proxy. Must be set before initialization. - **kTIMSetConfigIsOnlyLocalDNSSource** (bool) - Optional - If `true`, SDK will only use LocalDNS when selecting the optimal IP. ``` -------------------------------- ### Understanding lastMsg for Message Retrieval Source: https://im.sdk.qcloud.com/doc/zh-cn/structV2TIMMessageListGetOption Explains the 'lastMsg' parameter used as a starting point for fetching messages. It highlights its use in C2C messages and its distinction from 'lastMsgSeq' in group messages, particularly regarding the inclusion of the starting message in the returned list. ```Objective-C V2TIMMessage* lastMsg; // Used as the starting message for message retrieval. // For C2C messages, it's the only option. If not specified, the latest message is used. // For Group messages, it can be used alongside lastMsgSeq. If lastMsg is used, it's not included in the results. // If both lastMsg and lastMsgSeq are specified for group messages, lastMsg takes priority. ``` -------------------------------- ### TIM SDK Initialization and Uninitialization Source: https://im.sdk.qcloud.com/doc/zh-cn/TIMManagerFunction_8h Functions for initializing and uninitializing the IMSDK, along with retrieving the SDK version and server time. ```APIDOC ## TIMInit ### Description Initializes the IMSDK with the provided SDK App ID and configuration. ### Method `TIM_API int TIMInit (uint64_t sdk_app_id, const char *json_sdk_config)` ### Parameters - **sdk_app_id** (uint64_t) - Required - The unique application identifier for the SDK. - **json_sdk_config** (const char *) - Required - A JSON string containing SDK configuration parameters. ### Response - **Return Value** (int) - 0 on success, negative value on error. ## TIMUninit ### Description Uninitializes the IMSDK, releasing all associated resources. ### Method `TIM_API int TIMUninit (void)` ### Response - **Return Value** (int) - 0 on success, negative value on error. ## TIMGetSDKVersion ### Description Retrieves the current version of the IMSDK. ### Method `TIM_API const char * TIMGetSDKVersion (void)` ### Response - **Return Value** (const char *) - A string representing the SDK version. ## TIMGetServerTime ### Description Retrieves the current server time. ### Method `TIM_API uint64_t TIMGetServerTime () ### Response - **Return Value** (uint64_t) - The current server time as a timestamp. ``` -------------------------------- ### Set Global Message Receive Option (Timestamp-Based) Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMMessageManager Sets global message receiving preferences using a UTC timestamp for the start time and a duration. This is an alternative method for setting do-not-disturb periods. Requires the option, start timestamp, duration, and a callback. ```java void setAllReceiveMessageOpt(int opt, long startTimeStamp, long duration, V2TIMCallback callback); ``` -------------------------------- ### Set Global Message Receive Option (Timestamp-based, C++) Source: https://im.sdk.qcloud.com/doc/zh-cn/classV2TIMMessageManager Sets global message receiving options using a UTC timestamp for the start time. This allows for precise scheduling of 'do not disturb' periods. Requires the option, start timestamp, duration, and a callback. ```cpp virtual void SetAllReceiveMessageOpt(V2TIMReceiveMessageOpt _opt_, uint32_t _startTimeStamp_, uint32_t _duration_, V2TIMCallback* _callback_) ``` -------------------------------- ### V2TIMFriendInfo Constructor and Protected Methods Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMFriendInfo Information about the constructor and protected methods for the V2TIMFriendInfo object. ```APIDOC ## V2TIMFriendInfo Constructor and Protected Methods ### V2TIMFriendInfo() **Description**: Default constructor for the V2TIMFriendInfo object. **Method**: Constructor ### setFriendInfo(FriendInfo friendInfo) **Description**: Protected method to set the friend information using a FriendInfo object. This is an internal method and typically not called directly by the user. **Method**: POST/PUT (Conceptual) **Endpoint**: N/A (Method of an object) **Parameters**: #### Path Parameters None #### Query Parameters None #### Request Body - **friendInfo** (FriendInfo) - Required - The FriendInfo object containing the friend details to set. ``` -------------------------------- ### Set Global Message Receive Option (Time-Based) Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMMessageManager Sets global message receiving preferences with a specified start time and duration. This allows for implementing features like do-not-disturb for a defined period. Requires the option, start hour, minute, second, duration, and a callback. ```java void setAllReceiveMessageOpt(int opt, int startHour, int startMinute, int startSecond, long duration, V2TIMCallback callback); ``` -------------------------------- ### IM SDK 日志配置 Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMSDKConfig 设置和获取 IM SDK 的日志级别和日志监听器。这些方法必须在 SDK 初始化之前调用。设置日志监听器时,请注意回调可能在主线程频繁触发,避免执行耗时任务。 ```Java V2TIMSDKConfig config = new V2TIMSDKConfig(); config.setLogLevel(V2TIM_LOG_DEBUG); // 设置日志级别为 DEBUG V2TIMLogListener logListener = new V2TIMLogListener() { @Override public void onLog(int level, String log) { // 处理日志回调 System.out.println("Level: " + level + ", Log: " + log); } }; config.setLogListener(logListener); // 设置日志监听器 // 获取日志级别 int currentLogLevel = config.getLogLevel(); // 获取日志监听器 V2TIMLogListener currentLogListener = config.getLogListener(); ``` -------------------------------- ### Set Topic Introduction in IMSDK C++ Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMTopicInfo Sets the introductory text for the topic. This can be set during creation or modification. The introduction has a maximum length of 400 bytes and uses UTF-8 encoding. ```cpp void setIntroduction (String introduction) ``` -------------------------------- ### Get History Message List (Advanced) Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMMessageManager An advanced interface for retrieving historical messages with more granular control. Allows specifying options to fetch messages from the cloud or locally, and to control whether to get older or newer messages. Behavior is influenced by login status and network. ```java void getHistoryMessageList(V2TIMMessageListGetOption option, V2TIMValueCallback> callback); ``` -------------------------------- ### MsgGetMsgListParam Source: https://im.sdk.qcloud.com/doc/zh-cn/md_c_api_TIMMessageManagerJsonKey Parameters for the get history message interface. ```APIDOC ## MsgGetMsgListParam (获取历史消息接口的参数) ### Description Parameters for the get history message interface. ### Method Not Applicable (Structure Definition) ### Endpoint Not Applicable (Structure Definition) ### Parameters #### Request Body - **kTIMMsgGetMsgListParamLastMsg** (object Message) - Writable (Optional) - The specified message; cannot be null. - **kTIMMsgGetMsgListParamCount** (uint) - Writable (Optional) - Number of messages after the specified message. - **kTIMMsgGetMsgListParamIsRamble** (bool) - Writable (Optional) - Whether to fetch roaming messages. - **kTIMMsgGetMsgListMessageTypeArray** (array uint32) - Writable (Optional) - Message type collection to fetch. Valid when `kTIMMsgGetMsgListParamIsRamble` is false. An empty array fetches all types. See TIMElemType for values. - **kTIMMsgGetMsgListParamIsForward** (bool) - Writable (Optional) - Whether to sort messages in forward order. - **kTIMMsgGetMsgListParamLastMsgSeq** (uint64) - Writable (Optional) - Sequence number of the specified message. - **kTIMMsgGetMsgListParamTimeBegin** (uint64) - Writable (Optional) - Start time; UTC timestamp in seconds. - **kTIMMsgGetMsgListParamTimePeriod** (uint64) - Writable (Optional) - Duration in seconds. - **kTIMMsgGetMsgListParamMessageSeqArray** (array uint64) - Writable (Optional) - Collection of message sequence numbers to fetch; only valid for groups. ``` -------------------------------- ### Initialize IM SDK Source: https://im.sdk.qcloud.com/doc/zh-cn/classcom_1_1tencent_1_1imsdk_1_1v2_1_1V2TIMManager Initializes the IM SDK with the provided context, SDKAppID, configuration, and listener. Returns true on success, false otherwise. Requires Android Context. ```Java abstract boolean initSDK(Context _context, int _sdkAppID, V2TIMSDKConfig _config, V2TIMSDKListener _listener) ```