IMSDK
IM features a comprehensive suite of solutions including global access, one-to-one chat, group chat, message push, profile and relationship chain hosting, and account authentication. It also provides complete app access and backend management APIs.
V2TIMManagerabstract

Public Member Functions

virtual ~V2TIMManager ()
 
virtual void AddSDKListener (V2TIMSDKListener *listener)=0
 
virtual void RemoveSDKListener (V2TIMSDKListener *listener)=0
 
virtual bool InitSDK (uint32_t sdkAppID, const V2TIMSDKConfig &config)=0
 
virtual void UnInitSDK ()=0
 
virtual V2TIMString GetVersion ()=0
 
virtual int64_t GetServerTime ()=0
 
virtual void Login (const V2TIMString &userID, const V2TIMString &userSig, V2TIMCallback *callback)=0
 
virtual void Logout (V2TIMCallback *callback)=0
 
virtual V2TIMString GetLoginUser ()=0
 
virtual V2TIMLoginStatus GetLoginStatus ()=0
 
virtual void AddSimpleMsgListener (V2TIMSimpleMsgListener *listener)=0
 
virtual void RemoveSimpleMsgListener (V2TIMSimpleMsgListener *listener)=0
 
virtual V2TIMString SendC2CTextMessage (const V2TIMString &text, const V2TIMString &userID, V2TIMSendCallback *callback)=0
 
virtual V2TIMString SendC2CCustomMessage (const V2TIMBuffer &customData, const V2TIMString &userID, V2TIMSendCallback *callback)=0
 
virtual V2TIMString SendGroupTextMessage (const V2TIMString &text, const V2TIMString &groupID, V2TIMMessagePriority priority, V2TIMSendCallback *callback)=0
 
virtual V2TIMString SendGroupCustomMessage (const V2TIMBuffer &customData, const V2TIMString &groupID, V2TIMMessagePriority priority, V2TIMSendCallback *callback)=0
 
virtual void AddGroupListener (V2TIMGroupListener *listener)=0
 
virtual void RemoveGroupListener (V2TIMGroupListener *listener)=0
 
virtual void CreateGroup (const V2TIMString &groupType, const V2TIMString &groupID, const V2TIMString &groupName, V2TIMValueCallback< V2TIMString > *callback)=0
 
virtual void JoinGroup (const V2TIMString &groupID, const V2TIMString &message, V2TIMCallback *callback)=0
 
virtual void QuitGroup (const V2TIMString &groupID, V2TIMCallback *callback)=0
 
virtual void DismissGroup (const V2TIMString &groupID, V2TIMCallback *callback)=0
 
virtual void GetUsersInfo (const V2TIMStringVector &userIDList, V2TIMValueCallback< V2TIMUserFullInfoVector > *callback)=0
 
virtual void SetSelfInfo (const V2TIMUserFullInfo &info, V2TIMCallback *callback)=0
 
virtual void SubscribeUserInfo (const V2TIMStringVector &userIDList, V2TIMCallback *callback)=0
 
virtual void UnsubscribeUserInfo (const V2TIMStringVector &userIDList, V2TIMCallback *callback)=0
 
virtual void GetUserStatus (const V2TIMStringVector &userIDList, V2TIMValueCallback< V2TIMUserStatusVector > *callback)=0
 
virtual void SetSelfStatus (const V2TIMUserStatus &status, V2TIMCallback *callback)=0
 
virtual void SubscribeUserStatus (const V2TIMStringVector &userIDList, V2TIMCallback *callback)=0
 
virtual void UnsubscribeUserStatus (const V2TIMStringVector &userIDList, V2TIMCallback *callback)=0
 
virtual V2TIMMessageManagerGetMessageManager ()=0
 
virtual V2TIMGroupManagerGetGroupManager ()=0
 
virtual V2TIMCommunityManagerGetCommunityManager ()=0
 
virtual V2TIMConversationManagerGetConversationManager ()=0
 
virtual V2TIMFriendshipManagerGetFriendshipManager ()=0
 
virtual V2TIMOfflinePushManagerGetOfflinePushManager ()=0
 
virtual V2TIMSignalingManagerGetSignalingManager ()=0
 
virtual void CallExperimentalAPI (const V2TIMString &api, const void *param, V2TIMValueCallback< V2TIMBaseObject > *callback)=0
 

Static Public Member Functions

static V2TIMManagerGetInstance ()
 

Constructor & Destructor Documentation

◆ ~V2TIMManager()

virtual ~V2TIMManager ( )
inlinevirtual

Member Function Documentation

◆ GetInstance()

static V2TIMManager* GetInstance ( )
static

1.1 Get the V2TIMManager instance

◆ AddSDKListener()

virtual void AddSDKListener ( V2TIMSDKListener listener)
pure virtual

1.2 Add a Chat listener

◆ RemoveSDKListener()

virtual void RemoveSDKListener ( V2TIMSDKListener listener)
pure virtual

1.3 Remove a Chat listener

◆ InitSDK()

virtual bool InitSDK ( uint32_t  sdkAppID,
const V2TIMSDKConfig config 
)
pure virtual

1.4 Initialize the SDK.

◆ UnInitSDK()

virtual void UnInitSDK ( )
pure virtual

1.5 Uninitialize the SDK

◆ GetVersion()

virtual V2TIMString GetVersion ( )
pure virtual

1.6 Get the SDK version

Returns
Return the SDK version in string format, for example: 5.0.10

◆ GetServerTime()

virtual int64_t GetServerTime ( )
pure virtual

1.7 Get the server time

Returns
UTC timestamp, in seconds

◆ Login()

virtual void Login ( const V2TIMString userID,
const V2TIMString userSig,
V2TIMCallback callback 
)
pure virtual

2.1 Log in

userID and userSig must be set for login. For the generation of userSig, please see UserSig backend API

Attention
Note the following special logic:
  • The ticket expires before login: the callback of the login function returns the error ERR_USER_SIG_EXPIRED (6206) or ERR_SVR_ACCOUNT_USERSIG_EXPIRED (70001), and the user needs to generate a new userSig and log in again.
  • The ticket expires when the user is online: the V2TIMListener -> onUserSigExpired callback may also be triggered when the user is online. In this case, generate a new userSig and log in again.
  • An online user is kicked offline: this will be notified by the V2TIMListener -> onKickedOffline callback. After receiving this callback, you can notify the user via the UI and call login() to log the user in again.

◆ Logout()

virtual void Logout ( V2TIMCallback callback)
pure virtual

2.2 Log out

In the case of switching accounts, after the user logs out, they can log in again only after a logout callback is received (whether the logout succeeds or fails).

◆ GetLoginUser()

virtual V2TIMString GetLoginUser ( )
pure virtual

2.3 Get the logged in user

◆ GetLoginStatus()

virtual V2TIMLoginStatus GetLoginStatus ( )
pure virtual

2.4 Get the login status

If the user is already in the "logged in" or "logging in" state, do not frequently call the login API to log in.

Returns
login status

◆ AddSimpleMsgListener()

virtual void AddSimpleMsgListener ( V2TIMSimpleMsgListener listener)
pure virtual

3.1 Set the event listener for simple messages (text messages and custom messages)

Attention
For the event listener for advanced messages such as image, video, and voice messages, please see V2TIMMessageManager.addAdvancedMsgListener(V2TIMAdvancedMsgListener).

◆ RemoveSimpleMsgListener()

virtual void RemoveSimpleMsgListener ( V2TIMSimpleMsgListener listener)
pure virtual

3.2 Remove the event listener for simple messages (text messages and custom messages)

◆ SendC2CTextMessage()

virtual V2TIMString SendC2CTextMessage ( const V2TIMString text,
const V2TIMString userID,
V2TIMSendCallback callback 
)
pure virtual

3.3 Send a one-to-one text message (up to 12 KB)

Text messages support sensitive word filtering on the cloud. For example, if a text message sent by a user contains sensitive words, the callback will return the 80001 error code.

Returns
Unique ID of the message

◆ SendC2CCustomMessage()

virtual V2TIMString SendC2CCustomMessage ( const V2TIMBuffer customData,
const V2TIMString userID,
V2TIMSendCallback callback 
)
pure virtual

3.4 Send a one-to-one custom (signaling) message (up to 12 KB)

A custom message is essentially a binary buffer which allows you to customize your message format (often used to send signaling). Custom messages do not support sensitive word filtering on the cloud.

Returns
Unique ID of the message
Attention
Messages sent via this API are not pushed by default. To push the messages, call the V2TIMMessageManager::SendMessage API.

◆ SendGroupTextMessage()

virtual V2TIMString SendGroupTextMessage ( const V2TIMString text,
const V2TIMString groupID,
V2TIMMessagePriority  priority,
V2TIMSendCallback callback 
)
pure virtual

3.5 Send a group text message (up to 12 KB)

Parameters
priorityMessage priority. There is no guarantee that each message will reach all users, but higher-priority messages will have a higher delivery success rate.
  • HIGH :the message will be transferred with a high priority on the cloud. This setting is suitable for sending important messages in a group, such as text messages sent by the host.
  • NORMAL :the message will be transferred with the default priority on the cloud. This setting is suitable for sending less important messages in a group, such as on-screen comments sent by viewers.
Returns
Unique ID of the message

◆ SendGroupCustomMessage()

virtual V2TIMString SendGroupCustomMessage ( const V2TIMBuffer customData,
const V2TIMString groupID,
V2TIMMessagePriority  priority,
V2TIMSendCallback callback 
)
pure virtual

3.6 Send a group custom (signaling) message (up to 12 KB)

Parameters
priorityMessage priority. There is no guarantee that each message will reach all users, but higher-priority messages will have a higher delivery success rate.
  • HIGH :the message will be transferred with a high priority on the cloud. This setting is suitable for sending important messages in a group, such as mic connect invitations, competition invitation, gift-giving, and other key signaling.
  • NORMAL :the message will be transferred with the default priority on the cloud. This setting is suitable for sending less important signaling in a group, such as likes given by the audience.
Returns
Unique ID of the message
Attention
Messages sent via this API are not pushed by default. To push the messages, call the V2TIMMessageManager::SendMessage API.

◆ AddGroupListener()

virtual void AddGroupListener ( V2TIMGroupListener listener)
pure virtual

4.1 Add the group listener

◆ RemoveGroupListener()

virtual void RemoveGroupListener ( V2TIMGroupListener listener)
pure virtual

4.2 Remove the group listener

◆ CreateGroup()

virtual void CreateGroup ( const V2TIMString groupType,
const V2TIMString groupID,
const V2TIMString groupName,
V2TIMValueCallback< V2TIMString > *  callback 
)
pure virtual

4.3 Create a group

Parameters
groupType
groupTypeGroup type. The following group types are preset in the SDK. You can also customize group types in the console:
  • Work group (Work): supports up to 200 members; allows join by invitation only; suitable for work groups like those in WeCom (corresponding to Private groups in earlier versions)
  • Public group (Public): supports up to 2,000 members; allows anyone to apply to join the group, but requires group owner or admin approval for group joining; suitable for groups like interest groups managed by group owners in QQ
  • Meeting group (Meeting): supports up to 6,000 members; allows anyone to join and leave the group freely, without approval; suitable for scenarios such as video conference and online training (corresponding to ChatRoom groups in earlier versions)
  • Community : supports up to 100,000 members; allows anyone to join and leave the group freely, without approval; suitable for large community group chat scenarios such as knowledge sharing and game communication. supported only in 5.8 and later versions, need to buy Premium Edition.
  • Audio-video group (AVChatRoom): supports an unlimited number of members; allows anyone to join and leave the group freely; features high message throughput and is suitable for use as a chat room with high-concurrency on-screen comments in live streaming scenarios
groupIDCustom group ID. "null" can be passed in. When "null" is passed in, the system automatically assigns a group ID and returns it via a callback. Custom group ID of "Community" must be prefixed with "@TGS#_".
groupNameGroup name. The value cannot be "null". The maximum length is 100 bytes, using UTF-8 encoding, and 1 Chinese character occupies 3 bytes.
Attention
Note the following special logic:
  • Do not create groups with the same group ID under the same SDKAppID.
  • Audio-video group (AVChatRoom): After the process is restarted or the user is logged in again, for them to continue to receive messages from the same Audio-video group, please call joinGroup to join the group again.

◆ JoinGroup()

virtual void JoinGroup ( const V2TIMString groupID,
const V2TIMString message,
V2TIMCallback callback 
)
pure virtual

4.4 Join a group

Attention
Note the following special logic:
  • Work group (Work): users cannot proactively join a Work group. Only group members can call the V2TIMGroupManager::InviteUserToGroup API to invite users to join the group.
  • Public group (Public): admin approval is required for users to join a Public group. When receiving the V2TIMGroupListener -> onReceiveJoinApplication callback, the admin needs to call the V2TIMGroupListener::OnReceiveJoinApplication API to handle group joining requests.
  • Other groups: users can directly join such groups.
  • Audio-video group (AVChatRoom): After the process is restarted or the user is logged in again, for them to continue to receive messages from the same Audio-video group, please call joinGroup to join the group again.

◆ QuitGroup()

virtual void QuitGroup ( const V2TIMString groupID,
V2TIMCallback callback 
)
pure virtual

4.5 Quit a group

Attention
For public groups (Public), meeting groups (Meeting), and audio-video groups (AVChatRoom), the group owner cannot quit the group and can only call DismissGroup to delete the group.

◆ DismissGroup()

virtual void DismissGroup ( const V2TIMString groupID,
V2TIMCallback callback 
)
pure virtual

4.6 Delete a group

Attention
Note the following special logic:
  • For a work group (Work), even the group owner does not have the privilege to delete the group. To delete the group, you must have your service server call the RESTful API Deleting a Group.
  • For other group types, the group owner can delete the group.

◆ GetUsersInfo()

virtual void GetUsersInfo ( const V2TIMStringVector userIDList,
V2TIMValueCallback< V2TIMUserFullInfoVector > *  callback 
)
pure virtual

5.1 Get user profiles

Attention
  • To get your own profile, pass in your user ID.
  • You are advised to specify no more than 100 user IDs in userIDList at a time. A larger number may cause the request to be rejected by the backend due to an excessively large data packet. The maximum size of a data packet supported by the backend is 1 MB.

◆ SetSelfInfo()

virtual void SetSelfInfo ( const V2TIMUserFullInfo info,
V2TIMCallback callback 
)
pure virtual

5.2 Modify one's own user profile

◆ SubscribeUserInfo()

virtual void SubscribeUserInfo ( const V2TIMStringVector userIDList,
V2TIMCallback callback 
)
pure virtual

5.3 Subscribe to user profiles (supported only in Chat Premium 7.4 and later versions)

Parameters
userIDListuserIDList Identifiers for users whose profile will be subscribed.
Attention
  • This API is used to subscribe to stranger profiles, and after successfully subscribing, you will receive profile change notifications via the onUserInfoChanged callback.
  • A maximum of 200 subscriptions are allowed. When the limit is exceeded, the earliest subscriptions will be automatically eliminated.
  • You don't need to subscribe to your own or your friends' profiles. By default, any changes to your own and your friends' profiles will be notified via the onSelfInfoUpdated and onFriendInfoChange callback.

◆ UnsubscribeUserInfo()

virtual void UnsubscribeUserInfo ( const V2TIMStringVector userIDList,
V2TIMCallback callback 
)
pure virtual

5.4 Unsubscribe user profile (supported only in Chat Premium 7.4 and later versions)

Parameters
userIDListIdentifiers for users whose profiles you want to unsubscribe from. If userIDList is empty, all subscriptions will be canceled.

◆ GetUserStatus()

virtual void GetUserStatus ( const V2TIMStringVector userIDList,
V2TIMValueCallback< V2TIMUserStatusVector > *  callback 
)
pure virtual

5.5 Get user status information (supported only in Chat Premium 6.3 and later versions)

Parameters
userIDListList of identifier of the users whose information is to be obtained.
Attention
  • To get your own custom status, pass in your userID.
  • An error will be returned only if query fails for all specified users.

◆ SetSelfStatus()

virtual void SetSelfStatus ( const V2TIMUserStatus status,
V2TIMCallback callback 
)
pure virtual

5.6 Set your own user status (supported only in 6.3 and later versions)

Attention
You can only set your custom status (the customStatus field of V2TIMUserStatus) using this API.

◆ SubscribeUserStatus()

virtual void SubscribeUserStatus ( const V2TIMStringVector userIDList,
V2TIMCallback callback 
)
pure virtual

5.7 Subscribe to user status (supported only in Chat Premium 6.3 and later versions)

Parameters
userIDListIdentifiers for users whose status you want to subscribe to.
Attention
  • You will receive status change notifications via the onUserStatusChanged callback after successfully subscribing to user status.
  • To subscribe to the status of your friends, instead of calling this API, please configure it in the console.
  • You cannot use this API to subscribe to your own status. Instead, you can receive notifications about change of your own custom status via the onUserStatusChanged callback.
  • A maximum of 200 subscriptions are allowed. When the limit is exceeded, earlier subscriptions will be automatically canceled.

◆ UnsubscribeUserStatus()

virtual void UnsubscribeUserStatus ( const V2TIMStringVector userIDList,
V2TIMCallback callback 
)
pure virtual

5.8 Unsubscribe from user status (supported only in Chat Premium 6.3 and later versions)

Parameters
userIDListIdentifiers for users whose status you want to unsubscribe from. If useridList is empty, all subscriptions will be canceled.

◆ GetMessageManager()

virtual V2TIMMessageManager* GetMessageManager ( )
pure virtual

Advanced message feature entry

Returns
Advanced message management class instance

◆ GetGroupManager()

virtual V2TIMGroupManager* GetGroupManager ( )
pure virtual

Advanced group feature entry

Returns
Advanced group management class instance

◆ GetCommunityManager()

virtual V2TIMCommunityManager* GetCommunityManager ( )
pure virtual

Community feature entry

Returns
Community management class instance

◆ GetConversationManager()

virtual V2TIMConversationManager* GetConversationManager ( )
pure virtual

Conversation feature entry

Returns
Conversation management class instance

◆ GetFriendshipManager()

virtual V2TIMFriendshipManager* GetFriendshipManager ( )
pure virtual

Relationship chain feature entry

Returns
Relationship chain management class instance

◆ GetOfflinePushManager()

virtual V2TIMOfflinePushManager* GetOfflinePushManager ( )
pure virtual

Offline push feature entry

Returns
Offline push feature class instance

◆ GetSignalingManager()

virtual V2TIMSignalingManager* GetSignalingManager ( )
pure virtual

Signaling feature entry

Returns
Signaling management class instance

◆ CallExperimentalAPI()

virtual void CallExperimentalAPI ( const V2TIMString api,
const void *  param,
V2TIMValueCallback< V2TIMBaseObject > *  callback 
)
pure virtual

Experimental API

Parameters
apiAPI name
paramAPI parameter
Attention
This API provides some experimental features.