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.
V2TIMManager+Groupabstract
Swift - V2TIMManager
Swift

Extensions on V2TIMManager

Methods

create​Group(info:​member​List:​succ:​fail:​)

public func createGroup(info: V2TIMGroupInfo, memberList: Array<V2TIMCreateGroupMemberInfo>?, succ: V2TIMCreateGroupSucc?, fail: V2TIMFail?)  

1.1 Create a custom group (the advanced version API allows you to specify initial group members)

  • Limited by backgroud service, the number of memberList must be less than or equal to 20.

  • For other limits, please see @ref V2TIMManager.createGroup remarks.

Parameters

info V2TIMGroup​Info

Custom group information, including the groupID, groupType, groupName, notification, introduction, and faceURL fields

member​List Array<V2TIMCreate​Group​Member​Info>?

Specify initial group members (Audio-video groups do not support specifying initial group members. Pass in null for memberList.)

get​Joined​Group​List(succ:​fail:​)

public func getJoinedGroupList(succ: @escaping V2TIMGroupInfoListSucc, fail: @escaping V2TIMFail)  

1.2 Get the list of groups that the current user has joined

  • Audio-video groups (AVChatRoom) do not support this API.

  • This API implements frequency limit checks. It can be called by the SDK for up to 10 times per second. When the limit is exceeded, the error ERR_SDK_COMM_API_CALL_FREQUENCY_LIMIT (7008) is reported.

get​Groups​Info(group​IDList:​succ:​fail:​)

public func getGroupsInfo(groupIDList: Array<String>, succ: @escaping V2TIMGroupInfoResultListSucc, fail: @escaping V2TIMFail)  

2.1 Pull group profiles

Parameters

group​IDList Array<String>

List of group IDs

search​Groups(search​Param:​succ:​fail:​)

public func searchGroups(searchParam: V2TIMGroupSearchParam, succ: @escaping V2TIMGroupInfoListSucc, fail: @escaping V2TIMFail)  

2.2 Search for group profiles (supported only in Chat Premium 5.4.666 and later versions)

This API will search all the groups whose group name is included in the keyword list specifed in searchParam and return the group profiles list. The keyword list supports up to 5 keywords.

set​Group​Info(info:​succ:​fail:​)

public func setGroupInfo(info: V2TIMGroupInfo, succ: V2TIMSucc?, fail: V2TIMFail?)  

2.3 Modify group profiles

init​Group​Attributes(group​ID:​attributes:​succ:​fail:​)

public func initGroupAttributes(groupID: String, attributes: Dictionary<String, String>, succ: V2TIMSucc?, fail: V2TIMFail?)  

2.4 Initialize group attributes (this operation will clear the existing group attribute list)

  • Use limits of attributes::

  • Group attribute is supported only for audio-video groups (AVChatRoom) by 6.7 and earlier versions.

  • Group attribute is supported for 4 group types (AVChatRoom, Public, Meeting, Work groups) in 6.8 and later versions.

  • Group attribute is supported for all group types except topics in 7.0 and later versions.

  • Up to 16 keys are supported, with a length limit of 32 bytes.

  • The length limit for value is 4 KB.

  • The total length limit for attributes (including keys and values) is 16 KB.

  • The combined SDK rate limit for the initGroupAttributes, setGroupAttributes, and deleteGroupAttributes APIs is 10 calls every 5 seconds. If the limit is exceeded, the 8511 error code will be returned. The combined backend rate limit for the APIs is 5 calls per second. If the limit is exceeded, the 10049 error code will be returned.

  • The getGroupAttributes API can be called by the SDK for up to 20 times per 5 seconds.

  • Starting from version 5.6, when you modify group attributes for the first time after the app is started, please call getGroupAttributes to pull the latest group attributes before you initiate the modification operation.

  • Starting from version 5.6, when multiple users modify the same group attributes at the same time, only the first user can execute successfully, and other users will receive the 10056 error code. After receiving this error code, please call getGroupAttributes to update the locally stored group attributes to the latest before you initiate the modification operation.

set​Group​Attributes(group​ID:​attributes:​succ:​fail:​)

public func setGroupAttributes(groupID: String, attributes: Dictionary<String, String>, succ: V2TIMSucc?, fail: V2TIMFail?)  

2.5 Set group attributes. (If the group attributes already exist, their values are updated. Otherwise, the group attributes are added.)

  • Group attribute is supported only for audio-video groups (AVChatRoom) by 6.7 and earlier versions.

  • Group attribute is supported for 4 group types (AVChatRoom, Public, Meeting, Work groups) in 6.8 and later versions.

  • Group attribute is supported for all group types except topics in 7.0 and later versions.

delete​Group​Attributes(group​ID:​keys:​succ:​fail:​)

public func deleteGroupAttributes(groupID: String, keys: Array<String>?, succ: V2TIMSucc?, fail: V2TIMFail?)  

2.6 Delete specified group attributes (If null is passed in for keys, all group attributes are cleared.)

  • Group attribute is supported only for audio-video groups (AVChatRoom) by 6.7 and earlier versions.

  • Group attribute is supported for 4 group types (AVChatRoom, Public, Meeting, Work groups) in 6.8 and later versions.

  • Group attribute is supported for all group types except topics in 7.0 and later versions.

get​Group​Attributes(group​ID:​keys:​succ:​fail:​)

public func getGroupAttributes(groupID: String, keys: Array<String>?, succ: @escaping V2TIMGroupAttributeListSucc, fail: @escaping V2TIMFail)  

2.7 Get specified group attributes (If null is passed in for keys, all group attributes are obtained.)

  • Group attribute is supported only for audio-video groups (AVChatRoom) by 6.7 and earlier versions.

  • Group attribute is supported for 4 group types (AVChatRoom, Public, Meeting, Work groups) in 6.8 and later versions.

  • Group attribute is supported for all group types except topics in 7.0 and later versions.

get​Group​Online​Member​Count(group​ID:​succ:​fail:​)

public func getGroupOnlineMemberCount(groupID: String, succ: @escaping V2TIMGroupOnlineMemberCountSucc, fail: @escaping V2TIMFail)  

2.8 Get the number of online members of a group

  • This API is only supported by audio-video groups(AVChatRoom) before IMSDK 7.3 version.

  • You can call this API for all kinds of groups in IMSDK 7.3 and later versions.

set​Group​Counters(group​ID:​counters:​succ:​fail:​)

public func setGroupCounters(groupID: String, counters: Dictionary<String, Int>, succ: @escaping V2TIMGroupCounterResultSucc, fail: @escaping V2TIMFail)  

2.9 Set group counters (supported only in 7.0 and later versions)

  • If the group counters already exist, their values will be updated. Otherwise, the group counters will be added.

  • If the group counters are set successfully, their information will be returned via the succ callback.

  • Group counter is supported for all group types except community and topics.

get​Group​Counters(group​ID:​keys:​succ:​fail:​)

public func getGroupCounters(groupID: String, keys: Array<String>?, succ: @escaping V2TIMGroupCounterResultSucc, fail: @escaping V2TIMFail)  

2.10 Get group counters (supported only in 7.0 and later versions)

  • If keys is empty or nil, it means to obtain all counters in the group.

  • Group counter is supported for all group types except community and topics.

increase​Group​Counter(group​ID:​key:​value:​succ:​fail:​)

public func increaseGroupCounter(groupID: String, key: String, value: Int, succ: @escaping V2TIMGroupCounterResultSucc, fail: @escaping V2TIMFail)  

2.11 Increase group counters (supported only in 7.0 and later versions)

  • The callback will return the new value of the counter.

  • If the key specified already exists, its value will be increased. Otherwise, a key whose value is 0 will be added first, and then the value will be increased as specified.

  • Group counter is supported for all group types except community and topics.

Parameters

group​ID String

Group ID

key String

The key of counter

value Int

Increment of the group counter. The new value of the counter will be the old value plus this parameter (new_value = old_value + value).

succ @escaping V2TIMGroup​Counter​Result​Succ

Callback of success,returns the value of the current counter after increment

fail @escaping V2TIMFail

Callback of failure

decrease​Group​Counter(group​ID:​key:​value:​succ:​fail:​)

public func decreaseGroupCounter(groupID: String, key: String, value: Int, succ: @escaping V2TIMGroupCounterResultSucc, fail: @escaping V2TIMFail)  

2.12 Decrease group counters (supported only in 7.0 and later versions)

  • The callback will return the new value of the counter.

  • If the key specified already exists, its value will be decreased. Otherwise, a key whose value is 0 will be added first, and then the value will be decreased as specified.

  • Group counter is supported for all group types except community and topics.

Parameters

group​ID String

Group ID

key String

The key of counter

value Int

Decrement of the group counter. The new value of the counter will be the old value minus this parameter (new_value = old_value - value).

succ @escaping V2TIMGroup​Counter​Result​Succ

Callback of success,returns the value of the current counter after decrement

fail @escaping V2TIMFail

Callback of failure

get​Group​Member​List(group​ID:​filter:​next​Seq:​succ:​fail:​)

public func getGroupMemberList(groupID: String, filter: V2TIMGroupMemberFilter, nextSeq: UInt, succ: @escaping V2TIMGroupMemberInfoResultSucc, fail: @escaping V2TIMFail)  

3.1 Get the group member list

  • Restrictions for normal groups(Work, Meeting, Public):

  • The filter field can only be set to the value defined in V2TIMGroupMemberFilter, then you can get the members of the corresponding role.

  • Restrictions for audio-video groups(AVChatRoom):

  • If you set the filter to the value defined in V2TIMGroupMemberFullInfo, you will get all the members. The maximum number of members that can be obtained is 1,000. Newer members will appear at the top of the list. To use this feature, you need to upgrade to the Premium edition(supported only in 6.3 and later versions) and turn on "List of online audio-video group members" in the Chat console.

  • If you set the filter to custom markType defined by yourself, you can get the members of the corresponding markType in the Premium edition. Please refer to the API markGroupMemberList to mark group members.

  • After the app is restarted, please join the group again. Otherwise, the 10007 error code will be reported when you pull the group member list.

  • Only the following fields are supported in group member profiles: userID, nickName, faceURL, and role.

  • Restrictions for Community groups:

  • If you set the filter to the value defined in V2TIMGroupMemberFilter, you will get the the members of corresponding role.

  • If you set the filter to custom markType defined by yourself, you can get the members of the corresponding markType in the Premium Edition. Please refer to the API markGroupMemberList to mark group member list(supported only in 7.5 and later versions).

Parameters

filter V2TIMGroup​Member​Filter

Specify the group member type.

next​Seq UInt

Pulling-by-page flag. Pass in 0 when the information is pulled for the first time. If the nextSeq returned by the onSuccess callback is not 0, the results are paginated, and you need to pass in the nextSeq returned and pull again. Repeat until the nextSeq returned becomes 0.

get​Group​Members​Info(group​ID:​member​List:​succ:​fail:​)

public func getGroupMembersInfo(groupID: String, memberList: Array<String>, succ: @escaping V2TIMGroupMemberInfoListSucc, fail: @escaping V2TIMFail)  

3.2 Get the profiles of specified group members

search​Group​Members(search​Param:​succ:​fail:​)

public func searchGroupMembers(searchParam: V2TIMGroupMemberSearchParam, succ: @escaping V2TIMGroupMemberInfoListSearchSucc, fail: @escaping V2TIMFail)  

3.3 Search for group members (supported only in Chat Premium 5.4.666 and later versions)

Parameters

search​Param V2TIMGroup​Member​Search​Param

Search parameters

set​Group​Member​Info(group​ID:​info:​succ:​fail:​)

public func setGroupMemberInfo(groupID: String, info: V2TIMGroupMemberFullInfo, succ: V2TIMSucc?, fail: V2TIMFail?)  

3.4 Modify the profiles of specified group members

mute​Group​Member(group​ID:​member​User​ID:​mute​Time​Seconds:​succ:​fail:​)

public func muteGroupMember(groupID: String, memberUserID: String, muteTimeSeconds: UInt, succ: V2TIMSucc?, fail: V2TIMFail?)  

3.5 Mute a specific group member (this API can be called by the admin or group owner)

Parameters

mute​Time​Seconds UInt

Time period (seconds) during which the specified user will be muted.

mute​All​Group​Members(group​ID:​is​Mute:​succ:​fail:​)

public func muteAllGroupMembers(groupID: String, isMute: Bool, succ: V2TIMSucc?, fail: V2TIMFail?)  

3.6 Mute all group members (supported only in 7.5 and later versions)

  • Mute all group members indefinitely. You can set isMute to false to unmute all group members.

  • All group members will receive onAllGroupMembersMuted notification after this API is called successfully.

  • Only the group owner and admin can call this API.

Parameters

group​ID String

Group ID

is​Mute Bool

true means mute, false means unmute

invite​User​ToGroup(group​ID:​user​List:​succ:​fail:​)

public func inviteUserToGroup(groupID: String, userList: Array<String>, succ: V2TIMGroupMemberOperationResultListSucc?, fail: V2TIMFail?)  

3.7 Invite users to a group

  • Work group (Work): Anyone in the group can invite others to the group.

  • Meeting group (Meeting) and public group (Public): By default, users are not allowed to join the group through invitation. You can modify the groupApproveOpt field of V2TIMGroupInfo to open it. After that, all the group members can invite others to join the group.

  • Audio-video group (AVChatRoom): Inviting users to a group is not supported.

  • Limited by backgroud service, the number of userList must be less than or equal to 20.

kick​Group​Member(group​ID:​member​List:​reason:​duration:​succ:​fail:​)

public func kickGroupMember(groupID: String, memberList: Array<String>, reason: String?, duration: UInt, succ: V2TIMGroupMemberOperationResultListSucc?, fail: V2TIMFail?)  

3.8 Remove a member from a group

  • You can specificy a time interval in seconds during which the target users will not be allowed to join the group again after being kicked out of the group from 7.2 version.

  • Work group (Work): only the group owner or app admin can remove a member from a group.

  • Meeting group (Meeting) and public group (Public): the group owner, group admin, and app admin can remove a member from a group.

  • Audio-video group (AVChatRoom): only muting(muteGroupMember) is supported in versions prior to 6.6. Both muting(muteGroupMember) and kicking(kickGroupMember) are supported in 6.6 and later versions. You need to buy the Premium edition to use this feature.

  • Please refer to the following link for other usage restrictions of this interface.

Parameters

group​ID String

Group ID

member​List Array<String>

The list of members to remove

reason String?

The reason the member is removed

duration UInt

Time interval during which the target users will not be allowed to join the group again after being kicked out of the group in seconds

succ V2TIMGroup​Member​Operation​Result​List​Succ?

Callback of success

fail V2TIMFail?

Callback of failure

set​Group​Member​Role(group​ID:​member​User​ID:​new​Role:​succ:​fail:​)

public func setGroupMemberRole(groupID: String, memberUserID: String, newRole: V2TIMGroupMemberRole, succ: V2TIMSucc?, fail: V2TIMFail?)  

3.9 Set the role of a group member

  • Work group (Work) does not support setting group member roles.

  • Only the group owner can switch the role of a group member between common member and admin.

  • To transfer a group, please call the @ref transferGroupOwner API.

  • For a meeting group (Meeting), after a group member role is set, there will be no onGrantAdministrator or onRevokeAdministrator callback.

  • Roles that can be set are common member (V2TIM_GROUP_MEMBER_ROLE_MEMBER) and admin (V2TIM_GROUP_MEMBER_ROLE_ADMIN).

mark​Group​Member​List(group​ID:​member​List:​mark​Type:​enable​Mark:​succ:​fail:​)

public func markGroupMemberList(groupID: String, memberList: Array<String>, markType: UInt, enableMark: Bool, succ: V2TIMSucc?, fail: V2TIMFail?)  

3.10 Mark group members (supported only by the Premium edition)

  • Supported in Audio-video group (AVChatRoom) in 6.6 and later versions.

  • Supported in Community group in 7.5 and later versions.

  • Only the group owner has permission to mark other members in the group.

Parameters

group​ID String

Group's identifier.

member​List Array<String>

Group member's identifier list.

mark​Type UInt

The mark type is uint32_t, and the value must be equal or greater than 1000. You can customize it. A maximum of 10 marks are allowed to be defined in a group.

enable​Mark Bool

Set or remove. true means setting the mark, and false means removing the mark.

transfer​Group​Owner(group​ID:​member​User​ID:​succ:​fail:​)

public func transferGroupOwner(groupID: String, memberUserID: String, succ: V2TIMSucc?, fail: V2TIMFail?)  

3.11 Change the group owner

  • Common groups (Work, Public, and Meeting): only the group owner has the permission to change the group owner.

  • Audio-video group (AVChatRoom): changing the group owner is not supported.

kick​Group​Member(group​ID:​member​List:​reason:​succ:​fail:​)

@available(*, deprecated, message: "use kickGroupMember(groupID:memberList:reason:duration:succ:fail:) instead")
    public func kickGroupMember(groupID: String, memberList: Array<String>, reason: String?, succ: V2TIMGroupMemberOperationResultListSucc?, fail: V2TIMFail?)  

3.12 Remove a member from a group (supported for AVChatRoom only in Chat Premium 6.6 and later versions)

  • This API will be deprecated. Please call kickGroupMember:memberList:reason:duration:succ:fail: instead.

  • Work group (Work): only the group owner or app admin can remove a member from a group.

  • Meeting group (Meeting) and public group (Public): the group owner, group admin, and app admin can remove a member from a group.

  • Audio-video group (AVChatRoom): only muting(muteGroupMember) is supported in versions prior to 6.6. Both muting(muteGroupMember) and kicking(kickGroupMember) are supported in 6.6 and later versions.

  • Please refer to the following link for other usage restrictions of this interface.

get​Group​Application​List(succ:​fail:​)

public func getGroupApplicationList(succ: @escaping V2TIMGroupApplicationResultSucc, fail: @escaping V2TIMFail)  

4.1 Get the group joining request list

accept​Group​Application(application:​reason:​succ:​fail:​)

public func acceptGroupApplication(application: V2TIMGroupApplication, reason: String?, succ: V2TIMSucc?, fail: V2TIMFail?)  

4.2 Approve a group joining request

refuse​Group​Application(application:​reason:​succ:​fail:​)

public func refuseGroupApplication(application: V2TIMGroupApplication, reason: String?, succ: V2TIMSucc?, fail: V2TIMFail?)  

4.3 Reject a group joining request

set​Group​Application​Read(succ:​fail:​)

public func setGroupApplicationRead(succ: V2TIMSucc?, fail: V2TIMFail?)  

4.4 Mark the group joining request list as read