tencent cloud


SDK APIs (Android)

Last updated: 2022-04-21 16:07:55

    Do not use APIs of new and old versions at the same time.

    Initialization and Login APIs

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

    API Description
    initSDK Initializes the SDK.
    unInitSDK Uninitializes the SDK.
    getVersion Gets the version number.
    getServerTime Gets the server time.
    login Logs a user in.
    logout Logs a user out.
    getLoginStatus Gets the login status.
    getLoginUser Gets the UserID of the currently logged-in user.

    Simple Message APIs

    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 use it and addAdvancedMsgListener at the same time.
    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 (C2C) 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 Cancels an invitation.
    accept Accepts an invitation.
    reject Rejects an invitation.
    getSignalingInfo Gets the signaling information.
    addInvitedSignaling Adds invitation signaling (can be used for invitation signaling triggered by offline push messages for group invitations).

    Advanced Message APIs

    If you need to send/receive rich media messages (images, videos, files, etc.) and use advanced features such as recalling messages, marking messages as read, and querying message history, use the following advanced message APIs. Do not use simple messages APIs and advanced message APIs at the same time.

    API Description
    addAdvancedMsgListener Sets an event listener for advanced messages.
    Do not use it and addSimpleMsgListener at the same time.
    removeAdvancedMsgListener Removes the listener for advanced messages.
    createTextMessage Creates a text message.
    createTextAtMessage Creates an @ text message.
    createCustomMessage Creates a custom message.
    createImageMessage Creates an image message.
    createSoundMessage Creates a voice message.
    createVideoMessage Creates a video message.
    createFileMessage Creates a file message.
    createLocationMessage Creates a location message.
    createFaceMessage Creates an emoji message.
    createMergerMessage Creates a combined forward message.
    createForwardMessage Creates a single forward message.
    sendMessage Sends a message. The message object can be created using a createXXXMessage API.
    setC2CReceiveMessageOpt Sets the Mute Notifications option for one-to-one messages.
    getC2CReceiveMessageOpt Gets the Mute Notifications status for one-to-one messages.
    setGroupReceiveMessageOpt Sets the Mute Notifications option for group messages.
    getC2CHistoryMessageList Gets one-to-one (C2C) message history.
    getGroupHistoryMessageList Gets group message history.
    getHistoryMessageList Gets message history.
    revokeMessage Recalls a message. The message object can be created using a createXXXMessage API.
    markC2CMessageAsRead Marks one-to-one (C2C) messages as read.
    markGroupMessageAsRead Marks group messages as read.
    deleteMessageFromLocalStorage Deletes a message from local storage.
    deleteMessages Deletes messages from local storage and the cloud.
    clearC2CHistoryMessage Clears chat history with a user from local storage and the cloud.
    clearGroupHistoryMessage Clears chat history of a group from local storage and the cloud.
    insertGroupMessageToLocalStorage Adds a message to the group message list.
    insertC2CMessageToLocalStorage Inserts a message in a one-to-one chat.
    findMessages Finds local messages by msgID.
    searchLocalMessages Searches for local messages.
    sendMessageReadReceipts Sends message read receipts.
    getMessageReadReceipts Gets message read receipts.
    getGroupMessageReadMemberList Gets the list of group members who have read group messages.

    Group APIs

    Tencent Cloud IM SDK supports five preset group types, each of which pertains to different scenarios.

    • Work group (Work): users can join the group only after being invited by group members. This group type is the same as private group (Private) in earlier versions.
    • Public group (Public): users can join the group through requests, which need to be approved by the group owner or group admin.
    • Meeting group (Meeting): used together with TRTC to enable scenarios such as video conferencing and online education. Users can join and leave the group freely and view the message history before they join. Same as chat room (ChatRoom) in earlier versions.
    • Community group (Community): allows users to join and exit freely and is ideal for ultra-large community group chat scenarios, such as knowledge sharing and game communication. This feature is supported only in native SDK 5.8.1668 enhanced edition or higher and web SDK 2.17.0 or later. To use the feature, you need to purchase the Flagship Edition package and apply for activation.
    • Audio-video group (AVChatRoom): suitable for scenarios such as live streaming and chat rooms with on-screen comments. Users can join and leave the group freely. There is no limit on the number of group members.
    API Description
    setGroupListener Sets an event listener for groups.
    addGroupListener Adds a group listener.
    removeGroupListener Removes a group listener.
    createGroup Creates a (simple) group.
    createGroup Creates an (advanced) group. The group information and the initial group members can be set during group creation.
    joinGroup Joins a group.
    quitGroup Quits a group.
    dismissGroup Deletes a group. Only the group owner and group admin can delete a group.
    getJoinedGroupList Gets the list of groups the current user has joined, excluding audio-video groups.
    getGroupsInfo Pulls the profiles of groups.
    searchGroups Searches for groups.
    setGroupInfo Modifies the profile of a group.
    initGroupAttributes Initializes group attributes.
    setGroupAttributes Sets group attributes.
    deleteGroupAttributes Deletes group attributes.
    getGroupAttributes Gets group attributes.
    getGroupOnlineMemberCount Gets the number of online group members.
    getGroupMemberList Gets the group member list.
    getGroupMembersInfo Gets the profiles of specified group members.
    searchGroupMembers Searches for group members.
    setGroupMemberInfo Modifies the profile of a specified 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 Approves 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 count.

    API Description
    setConversationListener Sets a conversation listener.
    addConversationListener Adds a conversation listener.
    removeConversationListener Removes a conversation listener.
    getConversationList Gets the conversation list.
    getConversation Gets a conversation.
    getConversationList Gets multiple conversations.
    deleteConversation Deletes a conversation.
    setConversationDraft Sets a draft for a conversation.
    pinConversation Pins a conversation to the top.
    getTotalUnreadMessageCount Gets the total unread message count.

    User Profile APIs

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

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

    Offline Push APIs

    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 currently no unified push service in the Chinese mainland, you need to configure offline push for the mobile phones of different vendors separately.

    API Description
    setOfflinePushConfig Configures offline push.

    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 friend lists.

    API Description
    setFriendListener Sets a relationship chain listener to receive friend list and blocklist change events.
    addFriendListener Adds a relationship chain listener.
    removeFriendListener Removes a relationship chain listener.
    getFriendList Gets the friend list.
    getFriendsInfo Gets the profiles of specified friends.
    setFriendInfo Sets the profile of a specified friend.
    searchFriends Searches for friends.
    addFriend Adds a friend.
    deleteFromFriendList Deletes a friend.
    checkFriend Checks relationship with specified users.
    getFriendApplicationList Gets the list of friend requests.
    acceptFriendApplication Accepts a friend request.
    refuseFriendApplication Rejects a friend request.
    deleteFriendApplication Deletes a friend request.
    setFriendApplicationRead Marks a friend request as read.
    createFriendGroup Creates a friend list.
    getFriendGroups Gets the information of friend lists.
    deleteFriendGroup Deletes friend lists.
    renameFriendGroup Modifies the name of a friend list.
    addFriendsToFriendGroup Adds friends to a friend list.
    deleteFriendsFromFriendGroup Deletes friends from a friend list.
    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