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(Friendship)

Instance Methods

(void) - addFriendListener:
 
(void) - removeFriendListener:
 
(void) - setFriendListener:
 
(void) - getFriendList:fail:
 
(void) - getFriendsInfo:succ:fail:
 
(void) - setFriendInfo:succ:fail:
 
(void) - searchFriends:succ:fail:
 
(void) - addFriend:succ:fail:
 
(void) - deleteFromFriendList:deleteType:succ:fail:
 
(void) - checkFriend:checkType:succ:fail:
 
(void) - getFriendApplicationList:fail:
 
(void) - acceptFriendApplication:type:succ:fail:
 
(void) - acceptFriendApplication:type:remark:succ:fail:
 
(void) - refuseFriendApplication:succ:fail:
 
(void) - deleteFriendApplication:succ:fail:
 
(void) - setFriendApplicationRead:fail:
 
(void) - addToBlackList:succ:fail:
 
(void) - deleteFromBlackList:succ:fail:
 
(void) - getBlackList:fail:
 
(void) - createFriendGroup:userIDList:succ:fail:
 
(void) - getFriendGroupList:succ:fail:
 
(void) - deleteFriendGroup:succ:fail:
 
(void) - renameFriendGroup:newName:succ:fail:
 
(void) - addFriendsToFriendGroup:userIDList:succ:fail:
 
(void) - deleteFriendsFromFriendGroup:userIDList:succ:fail:
 
(void) - subscribeOfficialAccount:succ:fail:
 
(void) - unsubscribeOfficialAccount:succ:fail:
 
(void) - getOfficialAccountsInfo:succ:fail:
 
(void) - followUser:succ:fail:
 
(void) - unfollowUser:succ:fail:
 
(void) - getMyFollowingList:succ:fail:
 
(void) - getMyFollowersList:succ:fail:
 
(void) - getMutualFollowersList:succ:fail:
 
(void) - getUserFollowInfo:succ:fail:
 
(void) - checkFollowType:succ:fail:
 

Member Typedef Documentation

◆ V2TIMFriendInfoListSucc

- (typedef void(^ V2TIMFriendInfoListSucc) (NSArray< V2TIMFriendInfo * > *infoList))
protected

Callback definition on get friend list successfully.

◆ V2TIMFriendInfoResultListSucc

- (typedef void(^ V2TIMFriendInfoResultListSucc) (NSArray< V2TIMFriendInfoResult * > *resultList))
protected

Callback definition on get specified friends information successfully.

◆ V2TIMFriendOperationResultSucc

- (typedef void(^ V2TIMFriendOperationResultSucc) (V2TIMFriendOperationResult *result))
protected

Callback definition for friend related operation.

◆ V2TIMFriendOperationResultListSucc

- (typedef void(^ V2TIMFriendOperationResultListSucc) (NSArray< V2TIMFriendOperationResult * > *resultList))
protected

Callback definition for friend list related operation.

◆ V2TIMFriendCheckResultListSucc

- (typedef void(^ V2TIMFriendCheckResultListSucc) (NSArray< V2TIMFriendCheckResult * > *resultList))
protected

Callback definition for check relation type.

◆ V2TIMFriendGroupListSucc

- (typedef void(^ V2TIMFriendGroupListSucc) (NSArray< V2TIMFriendGroup * > *groups))
protected

Callback definition on get friend groups successfully.

◆ V2TIMFriendApplicationResultSucc

- (typedef void(^ V2TIMFriendApplicationResultSucc) (V2TIMFriendApplicationResult *result))
protected

Callback definition on get friend application list successfully.

◆ V2TIMOfficialAccountInfoResultListSucc

- (typedef void(^ V2TIMOfficialAccountInfoResultListSucc) (NSArray< V2TIMOfficialAccountInfoResult * > *resultList))
protected

Callback definition on get official account list successfully.

◆ V2TIMFollowOperationResultListSucc

- (typedef void(^ V2TIMFollowOperationResultListSucc) (NSArray< V2TIMFollowOperationResult * > *resultList))
protected

Callback definition for following related operation.

◆ V2TIMUserInfoResultSucc

- (typedef void(^ V2TIMUserInfoResultSucc) (NSString *nextCursor, NSArray< V2TIMUserFullInfo * > *userInfoList))
protected

Callback definition on get my following related user info list successfully.

◆ V2TIMFollowInfoResultListSucc

- (typedef void(^ V2TIMFollowInfoResultListSucc) (NSArray< V2TIMFollowInfo * > *resultList))
protected

Callback definition on get follow count info of specified user successfully.

◆ V2TIMFollowTypeCheckResultListSucc

- (typedef void(^ V2TIMFollowTypeCheckResultListSucc) (NSArray< V2TIMFollowTypeCheckResult * > *resultList))
protected

Callback definition for check follow type of specified user successfully.

Member Enumeration Documentation

◆ V2TIMFriendApplicationType

- (enum V2TIMFriendApplicationType) :
protected

Enumeration definition of friend request type.

Enumerator
V2TIM_FRIEND_APPLICATION_COME_IN 

Friend request received by me.

V2TIM_FRIEND_APPLICATION_SEND_OUT 

Friend request sent by me.

V2TIM_FRIEND_APPLICATION_BOTH 

Friend requests received and sent by me. Valid only during pulling.

◆ V2TIMFriendType

- (enum V2TIMFriendType) :
protected

Enumeration definition of friend type.

Enumerator
V2TIM_FRIEND_TYPE_SINGLE 

One-way friend.

V2TIM_FRIEND_TYPE_BOTH 

Two-way friend.

◆ V2TIMFriendRelationType

- (enum V2TIMFriendRelationType) :
protected

Enumeration definition of relation type.

Enumerator
V2TIM_FRIEND_RELATION_TYPE_NONE 

Not a friend.

V2TIM_FRIEND_RELATION_TYPE_IN_MY_FRIEND_LIST 

The peer party is on my friend list.

V2TIM_FRIEND_RELATION_TYPE_IN_OTHER_FRIEND_LIST 

I am on the peer party's friend list.

V2TIM_FRIEND_RELATION_TYPE_BOTH_WAY 

Two-way friend.

◆ V2TIMFriendAcceptType

- (enum V2TIMFriendAcceptType) :
protected

Enumeration definition of friend acception type.

Enumerator
V2TIM_FRIEND_ACCEPT_AGREE 

Accept the friend request (build a one-way friend relationship)

V2TIM_FRIEND_ACCEPT_AGREE_AND_ADD 

Accept the friend request and add the peer party as a friend (build a two-way friend relationship)

◆ V2TIMFollowType

- (enum V2TIMFollowType) :
protected

Enumeration definition of follow type.

Enumerator
V2TIM_FOLLOW_TYPE_NONE 

No relationship of following.

V2TIM_FOLLOW_TYPE_IN_MY_FOLLOWING_LIST 

The peer party is in my following list.

V2TIM_FOLLOW_TYPE_IN_MY_FOLLOWERS_LIST 

The peer party is in my followers list.

V2TIM_FOLLOW_TYPE_IN_BOTH_FOLLOWERS_LIST 

The peer party and I are mutually following each other.

Method Documentation

◆ addFriendListener:()

- (void) addFriendListener: (addFriendListener(listener:))  NS_SWIFT_NAME

1.1 Add the relationship chain listener

◆ removeFriendListener:()

- (void) removeFriendListener: (removeFriendListener(listener:))  NS_SWIFT_NAME

1.2 Remove the relationship chain listener

◆ setFriendListener:()

- (void) setFriendListener: (id< V2TIMFriendshipListener >)  listener

Set the relationship chain listener

It is deprecated and discouraged to call this function. Please call APIs ref addFriendListener and removeFriendListener instead.

◆ getFriendList:fail:()

- (void) getFriendList: (V2TIMFriendInfoListSucc succ
fail: (V2TIMFail)  fail 

2.1 Get the friend list

◆ getFriendsInfo:succ:fail:()

- (void) getFriendsInfo: (NSArray< NSString * > *)  userIDList
succ: (V2TIMFriendInfoResultListSucc succ
fail: (V2TIMFail)  fail 

2.2 Get the profiles of specified friends

Parameters
userIDListList of friends' userIDs
  • 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.

◆ setFriendInfo:succ:fail:()

- (void) setFriendInfo: (V2TIMFriendInfo *)  info
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

2.3 Set the profile of a specified friend

◆ searchFriends:succ:fail:()

- (void) searchFriends: (V2TIMFriendSearchParam *)  searchParam
succ: (V2TIMFriendInfoResultListSucc succ
fail: (V2TIMFail)  fail 

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

Attention
The API returns the user information stored locally. You can determine whether the user is a friend via getRelation in V2TIMFriendInfoResult.

◆ addFriend:succ:fail:()

- (void) addFriend: (V2TIMFriendAddApplication *)  application
succ: (V2TIMFriendOperationResultSucc succ
fail: (V2TIMFail)  fail 

2.5 Add a friend

◆ deleteFromFriendList:deleteType:succ:fail:()

- (void) deleteFromFriendList: (NSArray *)  userIDList
deleteType: (V2TIMFriendType deleteType
succ: (V2TIMFriendOperationResultListSucc succ
fail: (V2TIMFail)  fail 

2.6 Delete friends

Parameters
userIDListList of the friend userIDs to be deleted
  • 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.
deleteTypeDeletion type
  • V2TIMFriendInfo.V2TIM_FRIEND_TYPE_SINGLE: one-way friend
  • V2TIMFriendInfo.V2TIM_FRIEND_TYPE_BOTH: two-way friend

◆ checkFriend:checkType:succ:fail:()

- (void) checkFriend: (NSArray< NSString * > *)  userIDList
checkType: (V2TIMFriendType checkType
succ: (V2TIMFriendCheckResultListSucc succ
fail: (V2TIMFail)  fail 

2.7 Check your relationships with specified users

Parameters
userIDListList of the userIDs to be checked
checkTypeCheck type (one-way or two-way friend check)
succCallback on success
failCallback on fail
Attention
Notes for using checkType:
  • 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 四种情况

◆ getFriendApplicationList:fail:()

- (void) getFriendApplicationList: (V2TIMFriendApplicationResultSucc succ
fail: (V2TIMFail)  fail 

3.1 Get the friend request list

Attention
  • The friend request list includes the friend requests sent and received by yourself.
  • Up to 100 requests are supported.

◆ acceptFriendApplication:type:succ:fail:()

- (void) acceptFriendApplication: (V2TIMFriendApplication *)  application
type: (V2TIMFriendAcceptType acceptType
succ: (V2TIMFriendOperationResultSucc succ
fail: (V2TIMFail)  fail 

3.2 Accept friend requests

Parameters
applicationFriend request information, which will be returned when calling getFriendApplicationList is successful
acceptTypeBuild one-way or two-way friend relationships
  • V2TIMFriendApplication.V2TIM_FRIEND_ACCEPT_AGREE: agree to add as a one-way friend
  • V2TIMFriendApplication.V2TIM_FRIEND_ACCEPT_AGREE_AND_ADD: agree to add as a two-way friend

◆ acceptFriendApplication:type:remark:succ:fail:()

- (void) acceptFriendApplication: (V2TIMFriendApplication *)  application
type: (V2TIMFriendAcceptType acceptType
remark: (NSString *)  remark
succ: (V2TIMFriendOperationResultSucc succ
fail: (V2TIMFail)  fail 

3.3 Accept friend requests and set a remark

Parameters
applicationFriend request information, which will be returned when calling getFriendApplicationList is successful
acceptTypeBuild one-way or two-way friend relationships
  • V2TIMFriendApplication.V2TIM_FRIEND_ACCEPT_AGREE: agree to add as a one-way friend
  • V2TIMFriendApplication.V2TIM_FRIEND_ACCEPT_AGREE_AND_ADD: agree to add as a two-way friend
remarkFriend remark,maximum 96 bytes

◆ refuseFriendApplication:succ:fail:()

- (void) refuseFriendApplication: (V2TIMFriendApplication *)  application
succ: (V2TIMFriendOperationResultSucc succ
fail: (V2TIMFail)  fail 

3.4 Reject friend requests

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

◆ deleteFriendApplication:succ:fail:()

- (void) deleteFriendApplication: (V2TIMFriendApplication *)  application
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

3.5 Delete friend requests

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

◆ setFriendApplicationRead:fail:()

- (void) setFriendApplicationRead: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

3.6 Set a friend request as read

◆ addToBlackList:succ:fail:()

- (void) addToBlackList: (NSArray *)  userIDList
succ: (V2TIMFriendOperationResultListSucc succ
fail: (V2TIMFail)  fail 

4.1 Add users to the blocklist

◆ deleteFromBlackList:succ:fail:()

- (void) deleteFromBlackList: (NSArray *)  userIDList
succ: (V2TIMFriendOperationResultListSucc succ
fail: (V2TIMFail)  fail 

4.2 Delete users from the blocklist

◆ getBlackList:fail:()

- (void) getBlackList: (V2TIMFriendInfoListSucc succ
fail: (V2TIMFail)  fail 

4.3 Get the blocklist

◆ createFriendGroup:userIDList:succ:fail:()

- (void) createFriendGroup: (NSString *)  groupName
userIDList: (NSArray *)  userIDList
succ: (V2TIMFriendOperationResultListSucc succ
fail: (V2TIMFail)  fail 

5.1 Create a friend group

Parameters
groupNameFriend group name
userIDListList of the friend userIDs to be added to the friend group

◆ getFriendGroupList:succ:fail:()

- (void) getFriendGroupList: (NSArray *)  groupNameList
succ: (V2TIMFriendGroupListSucc succ
fail: (V2TIMFail)  fail 

5.2 Get friend group information

Parameters
groupNameListList of the names of the friend groups whose information is to be obtained. If null is passed in, the information of all friend groups is obtained.

◆ deleteFriendGroup:succ:fail:()

- (void) deleteFriendGroup: (NSArray *)  groupNameList
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.3 Delete friend groups

◆ renameFriendGroup:newName:succ:fail:()

- (void) renameFriendGroup: (NSString *)  oldName
newName: (NSString *)  newName
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.4 Modify the name of a friend group

◆ addFriendsToFriendGroup:userIDList:succ:fail:()

- (void) addFriendsToFriendGroup: (NSString *)  groupName
userIDList: (NSArray *)  userIDList
succ: (V2TIMFriendOperationResultListSucc succ
fail: (V2TIMFail)  fail 

5.5 Add friends to a friend group

◆ deleteFriendsFromFriendGroup:userIDList:succ:fail:()

- (void) deleteFriendsFromFriendGroup: (NSString *)  groupName
userIDList: (NSArray *)  userIDList
succ: (V2TIMFriendOperationResultListSucc succ
fail: (V2TIMFail)  fail 

5.6 Delete friends from a friend group

◆ subscribeOfficialAccount:succ:fail:()

- (void) subscribeOfficialAccount: (NSString *)  officialAccountID
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

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

◆ unsubscribeOfficialAccount:succ:fail:()

- (void) unsubscribeOfficialAccount: (NSString *)  officialAccountID
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

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

◆ getOfficialAccountsInfo:succ:fail:()

- (void) getOfficialAccountsInfo: (NSArray *)  officialAccountIDList
succ: (V2TIMOfficialAccountInfoResultListSucc succ
fail: (V2TIMFail)  fail 

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

Attention
When the officialAccountIDList is empty,it means to get the list of subscribed official accounts.

◆ followUser:succ:fail:()

- (void) followUser: (NSArray< NSString * > *)  userIDList
succ: (V2TIMFollowOperationResultListSucc succ
fail: (V2TIMFail)  fail 

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

Attention
The maximum number of users you can follow at one time is 20.

◆ unfollowUser:succ:fail:()

- (void) unfollowUser: (NSArray< NSString * > *)  userIDList
succ: (V2TIMFollowOperationResultListSucc succ
fail: (V2TIMFail)  fail 

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

Attention
The maximum number of users you can unfollow at one time is 20.

◆ getMyFollowingList:succ:fail:()

- (void) getMyFollowingList: (NSString *)  nextCursor
succ: (V2TIMUserInfoResultSucc succ
fail: (V2TIMFail)  fail 

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

Parameters
nextCursorPulling-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 @"".

◆ getMyFollowersList:succ:fail:()

- (void) getMyFollowersList: (NSString *)  nextCursor
succ: (V2TIMUserInfoResultSucc succ
fail: (V2TIMFail)  fail 

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

Parameters
nextCursorPulling-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 @"".

◆ getMutualFollowersList:succ:fail:()

- (void) getMutualFollowersList: (NSString *)  nextCursor
succ: (V2TIMUserInfoResultSucc succ
fail: (V2TIMFail)  fail 

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

Parameters
nextCursorPulling-by-page flag. It can be set to nil or "" when the information is pulled for thefirst 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 @"".

◆ getUserFollowInfo:succ:fail:()

- (void) getUserFollowInfo: (NSArray *)  userIDList
succ: (V2TIMFollowInfoResultListSucc succ
fail: (V2TIMFail)  fail 

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

◆ checkFollowType:succ:fail:()

- (void) checkFollowType: (NSArray< NSString * > *)  userIDList
succ: (V2TIMFollowTypeCheckResultListSucc succ
fail: (V2TIMFail)  fail 

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