With friends, it is the same as sending messages
Get Friends List
Sync your friends List
By default, the SDK synchronizes the buddy list with the server after each successful login, and the developer can disable this feature by setting it up disableAutoRequestAllContacts
or
1 |
- ( void )requestAllContactsFromServerWithResultBlock:(YWContactsOperationResultBlock)resultBlock; |
To proactively initiate a synchronization request.
How to invoke it?
Get local friends
Developers can use
123456 |
/// 获取不同排序和分组模式的FRC对象 - (YWFetchedResultsController *)fetchedResultsControllerWithListMode:(YWContactListMode)aMode imCore:(YWIMCore *)imCore; /// 使用关键字搜索用户,使用用户名 // 如果希望搜索好友,needIsFriend置为YES,否则可以置为NO - (YWFetchedResultsController *)fetchedResultsControllerWithSearchKeyword:(NSString *)aKeyword needIsFriend:(BOOL)needIsFriend imCore:(YWIMCore *)imCore; |
To get local friends.
For example:
Ywimcore *imcore = [Spkitexample sharedinstance].ywimkit.imcore; Getcontactservice] Fetchedresultscontrollerwithlistmode:ywcontactlistmodealphabetic Imcore:imcore];
Buddy Action
Friends add
You can initiate the Add Friend request in the following ways:
1234567891011 |
[[self.imkit.IMCore getContactService] addContact:person withIntroduction:@
"" withResultBlock:^(NSError *error, YWAddContactRequestResult result) {
NSString *title = nil;
if
(result == YWAddContactRequestResultError) {
title = @
"请求发送失败"
;
}
else if (result == YWAddContactRequestResultSuccess) {
title = @
"好友添加成功"
;
}
else {
title = @
"请求发送成功,等待对方验证"
;
}
[YWIndicator showTopToastTitle:title content:[NSString stringWithFormat:@
"添加%@"
, person.personId] userInfo:nil withTimeToDisplay:
1.5 andClickBlock:nil];
}];
|
The added party can use:
12 |
- ( void )addAddContactRequestBlockV2:( void (^)(YWPerson *person, YWContactAddRequestType type, BOOL isOffline, NSString *message))block forKey:(NSString *)key ofPriority:(YWBlockPriority)priority; |
To listen for the added request, or you can
1 |
- (YWConversation *)fetchContactSystemConversation; |
To get a list of friend requests.
For requests that are added, you can use:
123 |
- ( void )responseToAddContact:(BOOL)accept fromPerson:(YWPerson *)person withMessage:(NSString*)message andResultBlock:(YWAddContactResultBlock)resultBlock; |
This interface accepts or rejects.
When the added party is processed, the add initiator can pass:
12 |
- ( void )addAddContactResponseBlockV2:( void (^)(YWPerson *person, YWContactAddResponseType type, BOOL isOffline, NSString *message))block forKey:(NSString *)key ofPriority:(YWBlockPriority)priority; |
To get the results of each other's processing.
Note: The block added at the beginning of the add above needs to call the corresponding Remove method when not in use.
Delete Friends
Developers can use
1 |
- ( void )removeContact:(YWPerson *)persons withResultBlock:(YWRemoveContactResultBlock)resultBlock; |
To delete a friend by
12 |
- ( void )addFriendBeRemovedBlock:( void (^)(YWPerson *person, BOOL isOffline))block forKey:(NSString *)key ofPriority:(YWBlockPriority)priority; |
To receive the deleted callback.
Modify a friend's note name
Developers can use
1 |
- ( void )modifyContact:(YWPerson *)person WithNewNick:(NSString *)nickName andResultBlock:(YWContactOperationResultBlock)resultBlock; |
To change your friend's comment name by
1 |
- (NSString *)contactNickOfPerson:(YWPerson *)aPerson; |
To get a friend's note name.
Query if person is a friend
1 |
- (BOOL)ifPersonIsFriend:(YWPerson *)person; |
The red is the service provided by the Imcore object, except
Getcontactservice
And also
/** * Get long Connection service*/- (ID<IYWLoginService>) Getloginservice;/** * Access to session-related services*/- (ID<IYWConversationService>) Getconversationservice;/** * Get extended service*/- (ID<IYWExtensionService>) Getextensionservice;/** * Group related services*/- (ID<IYWTribeService>) Gettribeservice;/** * Roaming related services*/- (ID<IYWRoamingService>) Getroamingservice;/** * Contact Related services (people who build a relationship, called contacts)*/- (ID<IYWContactService>) Getcontactservice;/** * Cache related services, return nil before Imcore landing. * The cache here is related to Imcore, and the data from the [Ywapi Getglobalutilservice4cache] Global cache cannot be accessed from each other*/- (ID<IYWUtilService4Cache>) Getcacheservice;/** * Various setup Items*/- (ID<IYWSettingService>) Getsettingservice;/** * Get action related services*/- (ID<IYWActionService>) Getactionservice;/** * Get Ehelper service*/- (ID<IYWEHelperService>) Getehelperservice;
Ali Hundred Chuan iimsdk--friends, get Friends