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) - 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:
 

Protected Types

enum  V2TIMFriendApplicationType : NSInteger
 
enum  V2TIMFriendType : NSInteger
 
enum  V2TIMFriendRelationType : NSInteger
 
enum  V2TIMFriendAcceptType : NSInteger
 
typedef void(^ V2TIMFriendInfoListSucc) (NSArray< V2TIMFriendInfo * > *infoList)
 
typedef void(^ V2TIMFriendInfoResultListSucc) (NSArray< V2TIMFriendInfoResult * > *resultList)
 
typedef void(^ V2TIMFriendOperationResultSucc) (V2TIMFriendOperationResult *result)
 
typedef void(^ V2TIMFriendOperationResultListSucc) (NSArray< V2TIMFriendOperationResult * > *resultList)
 
typedef void(^ V2TIMFriendCheckResultListSucc) (NSArray< V2TIMFriendCheckResult * > *resultList)
 
typedef void(^ V2TIMFriendGroupListSucc) (NSArray< V2TIMFriendGroup * > *groups)
 
typedef void(^ V2TIMFriendApplicationResultSucc) (V2TIMFriendApplicationResult *result)
 

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.

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)

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 5.4.666 and later versions and need to buy Flagship Edition)

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

◆ 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

◆ refuseFriendApplication:succ:fail:()

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

3.3 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.4 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.5 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