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 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 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 IM listener

◆ RemoveSDKListener()

virtual void RemoveSDKListener ( V2TIMSDKListener listener)
pure virtual

1.3 Remove IM listener

◆ InitSDK()

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

1.4 Initialize the SDK.

It is deprecated and discouraged to call this function. Please call APIs ref initSDK defined in 1.2 and addIMSDKListener defined in 1.3 instead.

◆ 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
Server time, in seconds

◆ Login()

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

2.1 Login

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 user can receive the V2TIMListener -> onUserSigExpired callback when online, and the user also needs to generate a new userSig and log in again.
  • An online user is kicked offline: the SDK notifies the user of the logout via the V2TIMListener -> onKickedOffline callback and displays the logout notification on the UI, and the user can call login() to log in again.

◆ Logout()

virtual void Logout ( V2TIMCallback callback)
pure virtual

2.2 Logout

If the user logs out and switches the account, the user can log in again after the logout function calls back success or failure. Otherwise, login may fail.

◆ GetLoginUser()

virtual V2TIMString GetLoginUser ( )
pure virtual

2.3 Get the login 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 on which you can freely organize your message format (often used to send signaling). However, 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. Though there is no way for all messages to 100% reach every user, higher-priority messages will have a higher delivery success rate.
  • HIGH :the message will be transferred with high priority on the cloud. This setting is suitable for sending important messages in the group, such as text messages sent by host.
  • NORMAL :the message will be transferred with the default priority on the cloud. This setting is suitable for sending unimportant messages in the 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. Though there is no way for all messages to 100% reach every user, higher-priority messages will have a higher delivery success rate.
  • HIGH :the message will be transferred with high priority on the cloud. This setting is suitable for sending important messages in the 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 unimportant signaling in the group, such as audience's like notifications.
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 several common group types are preset in the SDK. You can also customize desired group types in the console:
  • Work group (Work): supports up to 200 members; does not allow proactive group joining and only allows users to be invited to join the group by group members; suitable for groups like work groups created in WeChat (corresponding to Private groups in the earlier version)
  • 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 the earlier version)
  • 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 Flagship 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 calls back the group ID via callback. Custom group ID of "Community" must be prefixed with "@TGS#_".
groupNameGroup name. The value cannot be "null" and can contain up to 30 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 logged in again, if you want to continue to receive messages from the Audio-video group, please call JoinGroup to rejoin the Audio-video group.

◆ 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 logged in again, if you want to continue to receive messages from the Audio-video group, please call JoinGroup to rejoin the Audio-video group.

◆ 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 to call the RESTful API Deleting a Group to delete the 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
Notes:
  • 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

◆ GetUserStatus()

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

5.3 Get user status information(supported only in 6.3 and later versions)

Parameters
userIDListList of identifier of the users whose information is to be obtained.
Attention
  • Passed yourself id to @userIDList, your custom status would be returned.
  • Only when all user's status obtained fail, @fail would be invoke.

◆ SetSelfStatus()

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

5.4 Setup user status for yourself (supported only in 6.3 and later versions)

Attention
Only the customStatus field of V2TIMUserStatus can be set for yourself.

◆ SubscribeUserStatus()

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

5.5 Subscribe user status (supported only in 6.3 and later versions)

Parameters
userIDListIdentifiers for users whose status will be subscribed.
Attention
:
  • You will receive the status change notification by implement the onUserStatusChanged callback after succeffully subscribe user status.
  • You can subscribe status of your friends by open the switch at console without call this API.
  • Status subscription of yourself is not supported. You can implement the onUserStatusChanged callback to obtain the status change notification for yourself which has been set on other devices.
  • There is a limit on the number of subscription list. The older subscriber will be automatically eliminated after exceeding the limit.

◆ UnsubscribeUserStatus()

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

5.6 Unsubscribe user status (supported only in 6.3 and later versions)

Parameters
userIDListIdentifiers for users whose status will be unsubscribed. If useridList is empty, status of all users will be unsubscribed.

◆ 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

◆ 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.