tencent cloud


SDK APIs (Flutter)

Last updated: 2022-05-30 14:50:38

    IM provides Flutter SDK API call examples. You can visit GitHub to obtain the source code.

    Initialization and Login APIs

    To use the Tencent Cloud IM service, you need to initialize the SDK and log in.

    API Description
    initSDK Initializes the SDK.
    unInitSDK Uninitializes the SDK.
    login Logs in.
    logout Logs out.
    getLoginUser Gets the UserID of the current login user.
    getLoginStatus Gets the login status.
    getServerTime Gets the current server time (not supported on web).
    getVersion Gets the version number.

    Simple Message Sending and Receiving APIs (Disused After v3.6.0)


    These simple message sending and receiving APIs will be disused after v3.6.0. If you are still using them, replace them as soon as possible.

    Use the following APIs for the sending and receiving of text and signaling (custom buffer) messages.

    API Description
    addSimpleMsgListener Sets an event listener for simple messages (text messages and custom messages). Do not confuse this API with the addAdvancedMsgListener API.
    removeSimpleMsgListener Removes the event listener for simple messages (text messages and custom messages).
    sendC2CTextMessage Sends a one-to-one (C2C) text message.
    sendC2CCustomMessage Sends a one-to-one custom (signaling) message.
    sendGroupTextMessage Sends a group text message.
    sendGroupCustomMessage Sends a group custom (signaling) message.

    Signaling APIs

    API Description
    addSignalingListener Adds a signaling listener.
    removeSignalingListener Removes a signaling listener.
    invite Invites a user.
    inviteInGroup Invites certain users in the group.
    cancel The inviter cancels the invitation.
    accept The invitee accepts the invitation.
    reject The invitee rejects the invitation.
    getSignalingInfo Gets signaling information.

    Message Creation APIs

    After a message is created, an id field will be returned. You can pass in the id field and related information to the message sending API (sendMessage) to send the message.

    API Description
    createTextMessage Creates a text message.
    createCustomMessage Creates a custom message.
    createImageMessage Creates an image message.
    createSoundMessage Creates an audio message.
    createVideoMessage Creates a video message.
    createTextAtMessage Creates an @ text message.
    createFileMessage Creates a file message.
    createLocationMessage Creates a location message.
    createFaceMessage Creates an emoji message.
    createMergerMessage Creates a combined message.

    Message Sending and Receiving APIs

    If you need to send or receive rich media messages (such as image, video, and file messages) and use advanced features such as recalling messages, marking messages as read, and querying message history, we recommend the following advanced message APIs. (The original APIs for simple message sending and receiving used by v3.6.0 and earlier versions have been disused. Please use new APIs to create and send messages.)

    API Description
    addAdvancedMsgListener Sets an event listener for advanced messages. Do not confuse this API with the addSimpleMsgListener API.
    removeAdvancedMsgListener Removes the event listener for advanced messages.
    getC2CHistoryMessageList Gets the one-to-one message history.
    getHistoryMessageList Gets the message history (advanced API).
    getHistoryMessageListWithoutFormat Gets the message history (advanced API) (without processing the data returned by native SDKs).
    getGroupHistoryMessageList Gets the group message history.
    markC2CMessageAsRead Marks a one-to-one message as read.
    markGroupMessageAsRead Marks a group message as read.
    markAllMessageAsRead Marks all messages as read.
    deleteMessageFromLocalStorage Deletes a message from the local storage.
    deleteMessages Deletes local and roaming messages.
    insertGroupMessageToLocalStorage Adds a message to the group message list.
    insertC2CMessageToLocalStorage Inserts a message in a one-to-one chat.
    clearC2CHistoryMessage Clears the chat history with a user from local storage and the cloud (without deleting the conversation).
    clearGroupHistoryMessage Clears the chat history of a group from local storage and the cloud.
    downloadMergerMessage Gets the sub messages of a combined message.
    reSendMessage Resends a message.
    setC2CReceiveMessageOpt Sets the one-to-one message receiving option for a user (batch setting supported).
    getC2CReceiveMessageOpt Queries the one-to-one message receiving option of a user.
    setGroupReceiveMessageOpt Modifies the group message receiving option.
    setLocalCustomData Sets custom message data (saved locally, will not be sent to the peer end, and will become invalid after the app is uninstalled and reinstalled).
    setLocalCustomInt Sets custom message data and marks whether a voice or video message is played (such a message will be saved locally, not be sent to the peer end, and become invalid after the app is uninstalled and reinstalled).
    revokeMessage Recalls a message. By default, you can recall only messages that are sent within two minutes. You can customize the time limit for message recall via the console (Feature Configuration > Login and Message > Message Recall Settings).
    sendMessage Sends a message.
    sendReplyMessage Sends a reply message.
    searchLocalMessages Searches for local messages.
    findMessages Queries local messages in a conversation by messageID.
    sendMessageReadReceptes Sends group message read receipts.
    getMessageReadReceptes Gets read receipts for messages sent by yourself.
    getgroupMessageReadMemeberList Gets the list of members who have (or have not) read a message sent by yourself.
    sendCustomMessage Sends a custom message (disused).
    sendImageMessage Sends an image message (disused).
    sendSoundMessage Sends a audio message (disused).
    sendVideoMessage Sends a video message (disused).
    sendFileMessage Sends a file message (disused).
    sendLocationMessage Sends a location message (disused).

    Group APIs

    Tencent Cloud IM SDK supports the following predefined group types, each of which pertains to different application scenarios:

    • Work group (Work): Users can join a work group only after being invited by members of the group.
    • Public group (Public): Users can join a public group through requests, which need to be approved by the group owner or group admin.
    • Meeting group (Meeting): When used together with TRTC, a meeting group can enable scenarios such as video conferencing and online education. Users can join and leave a meeting group freely and view the messages sent before they join the group.
    • Community (Community): A community allows users to join and leave freely and is ideal for ultra-large community group chat scenarios, such as knowledge sharing and game communication.
    • Audio-video group (AVChatRoom): An audio-video group allows users to join and leave freely and is suitable for scenarios such as live streaming and chat rooms with on-screen comments. There is no limit on the number of group members.
    API Description
    setGroupListener Sets an event listener for groups.
    createGroup Creates a group (simple API).
    createGroup Creates a group (Advanced API). You can set the group information and the initial group members during group creation.
    joinGroup Joins a group.
    quitGroup Quits a group.
    dismissGroup Disbands a group. Only the group owner and group admin can disband a group.
    getJoinedGroupList Gets the list of groups the current user has joined, excluding audio-video groups.
    getGroupsInfo Pulls the profile of a group.
    setGroupInfo Modifies the profile of a group.
    initGroupAttributes Initializes group attributes. This will clear the existing group attribute list.
    setGroupAttributes Sets group attributes. If the group attributes already exist, their values are updated. Otherwise, the group attributes are added.
    deleteGroupAttributes Deletes specified group attributes. Passing in null for keys means clearing all group attributes.
    getGroupAttributes Gets specified group attributes. Passing in null for keys means getting all group attributes.
    searchGroups Searches for the group list.
    searchGroupByID Searches for a group by groupID.
    getGroupOnlineMemberCount Gets the number of online users in an audio-video group.
    getGroupMemberList Gets the group member list.
    getGroupMembersInfo Gets the profile of a group member.
    setGroupMemberInfo Modifies the profile of a group member.
    searchGroupMembers Searches for a group member.
    muteGroupMember Mutes a group member.
    kickGroupMember Removes a member from a group.
    setGroupMemberRole Sets the role for a group member.
    transferGroupOwner Changes the group owner.
    inviteUserToGroup Invites users to a group.
    getGroupApplicationList Gets the list of requests to join a group.
    acceptGroupApplication Accepts a request to join a group.
    refuseGroupApplication Rejects a request to join a group.
    setGroupApplicationRead Marks the request list as read.

    Conversation List APIs

    The conversation list is the list a user sees on the first screen after logging in to WeChat or QQ. It includes elements such as conversation node, conversation name, group name, last message, and unread message count.

    API Description
    setConversationListener Sets a conversation listener.
    getConversationList Gets the conversation list.
    getConversationListWithoutFormat Gets the conversation list (unformatted).
    getConversationListByConversaionIds Gets the list of specified conversations by conversation IDs.
    pinConversation Pins a conversation to the top.
    getTotalUnreadMessageCount Gets the total unread message count of a conversation.
    getConversation Gets a specified conversation.
    deleteConversation Deletes a conversation.
    setConversationDraft Sets a draft for a conversation.

    User Profile APIs

    You can use the following APIs to query user profiles, modify your profile, and block messages from a specified user (that is, adding a specified user to the blocklist).

    API Description
    getUsersInfo Gets user profiles.
    setSelfInfo Modifies one’s own profile.
    addToBlackList Blocks the messages from a user, which means adding the user to the blocklist.
    deleteFromBlackList Unblocks the messages from a user, which means removing the user from the blocklist.
    getBlackList Gets the blocklist.

    Offline Push APIs

    We recommend you use the offline push service if you want your app to receive IM messages in real time when it runs in the background. As there is no unified push service in the Chinese mainland, you need to configure Android offline push for devices of different vendors separately.

    API Description
    setOfflinePushConfig Sets the offline push configuration.

    Friend Management APIs

    By default, Tencent Cloud IM does not check your relationship with a user when receiving and sending messages. You can enable Check Relationship for One-to-One Messages on Feature Configuration > Login and Message > Relationship Check in the IM console and use the following APIs to delete/add friends and manage your friends.

    API Description
    setFriendListener Sets a relationship chain listener to receive friend and blocklist change events.
    getFriendList Gets all friends.
    getFriendsInfo Gets the profiles of specified friends.
    setFriendInfo Sets the profile of a specified friend.
    addFriend Adds a friend.
    deleteFromFriendList Deletes a friend.
    checkFriend Checks your relationship with a specified user.
    getFriendApplicationList Gets the list of friend requests.
    acceptFriendApplication Accepts a friend request.
    refuseFriendApplication Rejects a friend request.
    deleteFriendApplication Deletes a friend request.
    setFriendApplicationRead Sets a friend request as read.
    createFriendGroup Creates a friend list.
    getFriendGroups Gets the information of friend lists.
    deleteFriendGroup Deletes a friend list.
    renameFriendGroup Modifies the name of a friend list.
    addFriendsToFriendGroup Adds friends to a friend list.
    deleteFriendsFromFriendGroup Deletes friends from a friend list.
    searchFriends Searches for friends.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support