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+Friendshipabstract
Swift - V2TIMManager
Swift

Extensions on V2TIMManager

Methods

add​Friend​Listener(listener:​)

public func addFriendListener(listener: V2TIMFriendshipListener)  

1.1 Add the relationship chain listener

remove​Friend​Listener(listener:​)

public func removeFriendListener(listener: V2TIMFriendshipListener)  

1.2 Remove the relationship chain listener

get​Friend​List(succ:​fail:​)

public func getFriendList(succ: @escaping V2TIMFriendInfoListSucc, fail: @escaping V2TIMFail)  

2.1 Get the friend list

get​Friends​Info(user​IDList:​succ:​fail:​)

public func getFriendsInfo(userIDList: Array<String>, succ: @escaping V2TIMFriendInfoResultListSucc, fail: @escaping V2TIMFail)  

2.2 Get the profiles of specified friends

  • You are advised to obtain a maximum of 100 user IDs 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.

Parameters

user​IDList Array<String>

List of friends' userIDs

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

public func setFriendInfo(info: V2TIMFriendInfo, succ: V2TIMSucc?, fail: V2TIMFail?)  

2.3 Set the profile of a specified friend

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

public func searchFriends(searchParam: V2TIMFriendSearchParam, succ: @escaping V2TIMFriendInfoResultListSucc, fail: @escaping V2TIMFail)  

2.4 Search for friends (supported only in Chat Premium 5.4.666 and later versions)

add​Friend(application:​succ:​fail:​)

public func addFriend(application: V2TIMFriendAddApplication, succ: V2TIMFriendOperationResultSucc?, fail: V2TIMFail?)  

2.5 Add a friend

delete​From​Friend​List(user​IDList:​delete​Type:​succ:​fail:​)

public func deleteFromFriendList(userIDList: Array<String>, deleteType: V2TIMFriendType, succ: V2TIMFriendOperationResultListSucc?, fail: V2TIMFail?)  

2.6 Delete friends

  • You are advised to delete a maximum of 100 user IDs 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.

  • @ref V2TIMFriendInfo.V2TIM_FRIEND_TYPE_SINGLE: one-way friend

  • @ref V2TIMFriendInfo.V2TIM_FRIEND_TYPE_BOTH: two-way friend

Parameters

user​IDList Array<String>

List of the friend userIDs to be deleted

delete​Type V2TIMFriend​Type

Deletion type

check​Friend(user​IDList:​check​Type:​succ:​fail:​)

public func checkFriend(userIDList: Array<String>, checkType: V2TIMFriendType, succ: @escaping V2TIMFriendCheckResultListSucc, fail: @escaping V2TIMFail)  

2.7 Check your relationships with specified users

  • If V2TIM_FRIEND_TYPE_SINGLE is passed in for checkType, the possible results are V2TIM_FRIEND_RELATION_TYPE_NONE and V2TIM_FRIEND_RELATION_TYPE_IN_MY_FRIEND_LIST.

  • If V2TIM_FRIEND_TYPE_BOTH is passed in for checkType, the possible results are V2TIM_FRIEND_RELATION_TYPE_NONE, V2TIM_FRIEND_RELATION_TYPE_IN_MY_FRIEND_LIST, V2TIM_FRIEND_RELATION_TYPE_IN_OTHER_FRIEND_LIST, and V2TIM_FRIEND_RELATION_TYPE_BOTH_WAY. V2TIM_FRIEND_RELATION_TYPE_IN_OTHER_FRIEND_LIST、V2TIM_FRIEND_RELATION_TYPE_BOTH_WAY 四种情况

Parameters

user​IDList Array<String>

List of the userIDs to be checked

check​Type V2TIMFriend​Type

Check type (one-way or two-way friend check)

succ @escaping V2TIMFriend​Check​Result​List​Succ

Callback on success

fail @escaping V2TIMFail

Callback on fail

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

public func getFriendApplicationList(succ: @escaping V2TIMFriendApplicationResultSucc, fail: @escaping V2TIMFail)  

3.1 Get the friend request list

accept​Friend​Application(application:​accept​Type:​succ:​fail:​)

public func acceptFriendApplication(application: V2TIMFriendApplication, acceptType: V2TIMFriendAcceptType, succ: V2TIMFriendOperationResultSucc?, fail: V2TIMFail?)  

3.2 Accept friend requests

  • @ref V2TIMFriendApplication.V2TIM_FRIEND_ACCEPT_AGREE: agree to add as a one-way friend

  • @ref V2TIMFriendApplication.V2TIM_FRIEND_ACCEPT_AGREE_AND_ADD: agree to add as a two-way friend

Parameters

application V2TIMFriend​Application

Friend request information, which will be returned when calling getFriendApplicationList is successful

accept​Type V2TIMFriend​Accept​Type

Build one-way or two-way friend relationships

accept​Friend​Application(application:​accept​Type:​remark:​succ:​fail:​)

public func acceptFriendApplication(application: V2TIMFriendApplication, acceptType: V2TIMFriendAcceptType, remark: String, succ: V2TIMFriendOperationResultSucc?, fail: V2TIMFail?)  

3.3 Accept friend requests and set a remark

  • @ref V2TIMFriendApplication.V2TIM_FRIEND_ACCEPT_AGREE: agree to add as a one-way friend

  • @ref V2TIMFriendApplication.V2TIM_FRIEND_ACCEPT_AGREE_AND_ADD: agree to add as a two-way friend

Parameters

application V2TIMFriend​Application

Friend request information, which will be returned when calling getFriendApplicationList is successful

accept​Type V2TIMFriend​Accept​Type

Build one-way or two-way friend relationships

remark String

Friend remark,maximum 96 bytes

refuse​Friend​Application(application:​succ:​fail:​)

public func refuseFriendApplication(application: V2TIMFriendApplication, succ: V2TIMFriendOperationResultSucc?, fail: V2TIMFail?)  

3.4 Reject friend requests

Parameters

application V2TIMFriend​Application

Friend request information, which will be returned when calling @ref getFriendApplicationList is successful

delete​Friend​Application(application:​succ:​fail:​)

public func deleteFriendApplication(application: V2TIMFriendApplication, succ: V2TIMSucc?, fail: V2TIMFail?)  

3.5 Delete friend requests

Parameters

application V2TIMFriend​Application

Friend request information, which will be returned when calling @ref getFriendApplicationList is successful

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

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

3.6 Set a friend request as read

add​ToBlack​List(user​IDList:​succ:​fail:​)

public func addToBlackList(userIDList: Array<String>, succ: V2TIMFriendOperationResultListSucc?, fail: V2TIMFail?)  

4.1 Add users to the blocklist

delete​From​Black​List(user​IDList:​succ:​fail:​)

public func deleteFromBlackList(userIDList: Array<String>, succ: V2TIMFriendOperationResultListSucc?, fail: V2TIMFail?)  

4.2 Delete users from the blocklist

get​Black​List(succ:​fail:​)

public func getBlackList(succ: @escaping V2TIMFriendInfoListSucc, fail: @escaping V2TIMFail)  

4.3 Get the blocklist

create​Friend​Group(group​Name:​user​IDList:​succ:​fail:​)

public func createFriendGroup(groupName: String, userIDList: Array<String>?, succ: V2TIMFriendOperationResultListSucc?, fail: V2TIMFail?)  

5.1 Create a friend group

Parameters

group​Name String

Friend group name

user​IDList Array<String>?

List of the friend userIDs to be added to the friend group

get​Friend​Group​List(group​Name​List:​succ:​fail:​)

public func getFriendGroupList(groupNameList: Array<String>?, succ: @escaping V2TIMFriendGroupListSucc, fail: @escaping V2TIMFail)  

5.2 Get friend group information

Parameters

group​Name​List Array<String>?

List of the names of the friend groups whose information is to be obtained. If nil is passed in, the information of all friend groups is obtained.

delete​Friend​Group(group​Name​List:​succ:​fail:​)

public func deleteFriendGroup(groupNameList: Array<String>, succ: V2TIMSucc?, fail: V2TIMFail?)  

5.3 Delete friend groups

rename​Friend​Group(old​Name:​new​Name:​succ:​fail:​)

public func renameFriendGroup(oldName: String, newName: String, succ: V2TIMSucc?, fail: V2TIMFail?)  

5.4 Modify the name of a friend group

add​Friends​ToFriend​Group(group​Name:​user​IDList:​succ:​fail:​)

public func addFriendsToFriendGroup(groupName: String, userIDList: Array<String>, succ: V2TIMFriendOperationResultListSucc?, fail: V2TIMFail?)  

5.5 Add friends to a friend group

delete​Friends​From​Friend​Group(group​Name:​user​IDList:​succ:​fail:​)

public func deleteFriendsFromFriendGroup(groupName: String, userIDList: Array<String>, succ: V2TIMFriendOperationResultListSucc?, fail: V2TIMFail?)  

5.6 Delete friends from a friend group

subscribe​Official​Account(official​Account​ID:​succ:​fail:​)

public func subscribeOfficialAccount(officialAccountID: String, succ: V2TIMSucc?, fail: V2TIMFail?)  

6.1 Subscribe to an official account.(supported only in 7.6 and later versions)

unsubscribe​Official​Account(official​Account​ID:​succ:​fail:​)

public func unsubscribeOfficialAccount(officialAccountID: String, succ: V2TIMSucc?, fail: V2TIMFail?)  

6.2 Unsubscribe from an official account..(supported only in 7.6 and later versions)

get​Official​Accounts​Info(official​Account​IDList:​succ:​fail:​)

public func getOfficialAccountsInfo(officialAccountIDList: Array<String>, succ: V2TIMOfficialAccountInfoResultListSucc?, fail: V2TIMFail?)  

6.3 Get a list of official accounts.(supported only in 7.6 and later versions)

follow​User(user​IDList:​succ:​fail:​)

public func followUser(userIDList: Array<String>,  succ: V2TIMFollowOperationResultListSucc?, fail: V2TIMFail?)  

7.1 Follow users (supported only in Chat Premium 7.8 and later versions)

unfollow​User(user​IDList:​succ:​fail:​)

public func unfollowUser(userIDList: Array<String>, succ: V2TIMFollowOperationResultListSucc?, fail: V2TIMFail?)  

7.2 Unfollow users (supported only in Chat Premium 7.8 and later versions)

get​MyFollowing​List(next​Cursor:​succ:​fail:​)

public func getMyFollowingList(nextCursor: String?, succ: V2TIMUserInfoResultSucc?, fail: V2TIMFail?)  

7.3 Get a list of the users I follow (supported only in Chat Premium 7.8 and later versions)

Parameters

next​Cursor String?

Pulling-by-page flag. It can be set to nil or @"" when the information is pulled for the first time. If the API is called successfully and nextCursor returned by the callback is not @"", the results are paginated. The value of this field should be passed in for the next pulling until nextCursor becomes @"".

get​MyFollowers​List(next​Cursor:​succ:​fail:​)

public func getMyFollowersList(nextCursor: String?, succ: V2TIMUserInfoResultSucc?, fail: V2TIMFail?)  

7.4 Get a list of my followers (supported only in Chat Premium 7.8 and later versions)

Parameters

next​Cursor String?

Pulling-by-page flag. It can be set to nil or @"" when the information is pulled for the first time. If the API is called successfully and nextCursor returned by the callback is not @"", the results are paginated. The value of this field should be passed in for the next pulling until nextCursor becomes @"".

get​Mutual​Followers​List(next​Cursor:​succ:​fail:​)

public func getMutualFollowersList(nextCursor: String?, succ: V2TIMUserInfoResultSucc?, fail: V2TIMFail?)  

7.5 Get a list of my mutual followers (supported only in Chat Premium 7.8 and later versions)

Parameters

next​Cursor String?

Pulling-by-page flag. It can be set to nil or @"" when the information is pulled for the first time. If the API is called successfully and nextCursor returned by the callback is not @"", the results are paginated. The value of this field should be passed in for the next pulling until nextCursor becomes @"".

get​User​Follow​Info(user​IDList:​succ:​fail:​)

public func getUserFollowInfo(userIDList: Array<String>, succ: V2TIMFollowInfoResultListSucc?, fail: V2TIMFail?)  

7.6 Get the follow info of specified users (supported only in Chat Premium 7.8 and later versions)

check​Follow​Type(user​IDList:​succ:​fail:​)

public func checkFollowType(userIDList: Array<String>, succ: V2TIMFollowTypeCheckResultListSucc?, fail: V2TIMFail?)  

7.7 Check follow type of specified users (supported only in Chat Premium 7.8 and later versions)