SDK APIs (iOS and Mac)

Last updated: 2020-08-03 11:28:47

    Note:

    Stick on the new API. Do not use it with the older versions.

    Initialization and Login APIs

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

    API Description
    [initSDK].(http://doc.qcloudtrtc.com/im/interfaceV2TIMManager.html#a8035eed3a7c9b3b1c229196ac7bc5da6) Initializes the SDK.
    unInitSDK Uninitializes the SDK.
    login Logs in.
    logout Logs out.
    getLoginStatus Obtains the login status.
    getLoginUser Obtains the UserID of the current login user.

    Simple Message APIs

    Use the following message APIs if you only need to use text and signaling (a custom buffer) messages.

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

    Advanced Message APIs

    If you need rich-media messages (images, video, files, and others) and advanced features such as receiving and sending messages, recalling messages, marking messages as read, and querying the message history, use the following advanced message APIs. Do not use a mixture of simple message APIs and advanced message APIs.

    API Description
    addAdvancedMsgListener Sets an event listener for advanced messages.
    Do not use it with addSimpleMsgListener.
    removeAdvancedMsgListener Removes the listener for advanced messages.
    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.
    createFileMessage Creates a file message.
    createLocationMessage Creates a location message.
    createFaceMessage Creates an emoji message.
    sendMessage Sends a message. The message object can be created through the createXXXMessage API.
    revokeMessage Recalls a message. The message object can be created through the createXXXMessage API.
    getC2CHistoryMessageList Obtains the one-to-one chat (C2C) message history.
    getGroupHistoryMessageList Obtains the group chat message history.
    markC2CMessageAsRead Marks one-to-one chat (C2C) messages as read.
    markGroupMessageAsRead Marks group messages as read.
    deleteMessageFromLocalStorage Deletes a message from the local storage.
    insertGroupMessageToLocalStorage Adds a message to the group message list.

    Group APIs

    Tencent Cloud IM SDK supports four predefined group types, each of which pertains to different application scenarios.

    • Work group (Work): is similar to a regular WeChat group. Users can only join the group by being invited by existing group members.
    • Public group (Public): is similar to a QQ group. Users can join the group through applications, which need to be approved by the group owner or group admin.
    • Meeting group (Meeting): when used with TRTC, it is ideal for scenarios such as video conferencing and online education. Users can join and exit the group freely and view the message history for the periods before they join the group.
    • Live-streaming group (AVChatRoom): is suitable for scenarios such as live streaming and chat room with on-screen comments. Users can join and exit the group freely. There is no limit on the number of group members.
    API Description
    setGroupListener Sets a group listener.
    createGroup Creates a group (simple).
    createGroup Creates a group (advanced). Group information and initial group members can be set during group creation.
    joinGroup Joins a group.
    quitGroup Quits a group.
    dismissGroup Disbands a group. Only the group owner and group admin can disband the group.
    getJoinedGroupList Obtains the list of groups the current user has joined, excluding live-streaming groups.
    getGroupsInfo Pulls profiles of groups.
    setGroupInfo Modifies the profile of a group.
    setReceiveMessageOpt Sets the group message receiving option.
    getGroupMemberList Obtains the group member list.
    getGroupMembersInfo Obtains the profiles of specified group members.
    setGroupMemberInfo Modifies the profile of a specified group member.
    muteGroupMember Mutes a group member.
    inviteUserToGroup Invites users to a group.
    kickGroupMember Removes members from a group.
    setGroupMemberRole Sets the role for a group member.
    transferGroupOwner Transfers the ownership of a group.
    getGroupApplicationList Obtains the list of applications to join a group.
    acceptGroupApplication Accepts an application to join a group.
    refuseGroupApplication Rejects an application to join a group.
    setGroupApplicationRead Marks the application 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 the conversation node, conversation name, group name, last message, and unread count.

    API Description
    setConversationListener Sets a conversation listener.
    getConversationList Obtains the conversation list.
    deleteConversation Deletes a conversation.
    setConversationDraft Sets a draft for a conversation.

    User Profile APIs

    These APIs are uesd to query user profiles, modify the user profile of oneself, and block messages from a specified user (that is, add a specified user to the blocklist).

    API Description
    getUsersInfo Obtains users’ profiles.
    setSelfInfo Modifies the user profile of oneself.
    addToBlackList Blocks messages from a specified user, which means to add the user to the blocklist.
    deleteFromBlackList Unblocks messages from a specified user, which means to remove the user from the blocklist.
    getBlackList Obtains the blocklist.

    Offline Push APIs

    Use the offline push service if you want your app to receive IM messages in real time when it is running in the background. For detailed configuration, see Offline Push.

    API Description
    setAPNSListener Sets an APNs listener.
    setAPNS Sets the offline push configuration.

    Friend Management APIs

    By default, Tencent Cloud IM does not check for the relationship when receiving and sending messages. You can toggle on "Check Relationship for One-to-One Messages" by navigating to Console > Feature Configuration > Login and Message > Relationship Check and use the following APIs to delete or add friends and manage the friend list.

    API Description
    setFriendListener Sets a relationship chain and a friend profile listener.
    getFriendList Obtains the friend list.
    getFriendsInfo Obtains the profiles of specified friends.
    setFriendInfo Sets the profile of a specified friend.
    addFriend Adds a friend.
    deleteFromFriendList Deletes friends.
    checkFriend Checks the relationship with a specified user.
    getFriendApplicationList Obtains 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 group.
    getFriendGroups Obtains the information of friend groups.
    deleteFriendGroup Deletes friend groups.
    renameFriendGroup Changes the name of a friend group.
    addFriendsToFriendGroup Adds friends to a friend group.
    deleteFriendsFromFriendGroup Deletes friends from a friend group.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help