SDKsiOS
Delete a friend
Delete an iOS friend relationship.
Remove a friendship relationship between the authenticated user and a target contact using deleteFriend:onSuccess:onFailure:.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
friendUserID | NSString * | Yes | Target friend user ID to delete. |
Code example
[[OIMManager manager] deleteFriend:@"user_b"
onSuccess:^(NSString *data) {
[friendStore removeUserID:@"user_b"];
}
onFailure:^(NSInteger code, NSString *message) {
NSLog(@"deleteFriend failed: %ld %@", (long)code, message);
}];Return value
The onSuccess callback confirms that OpenIMServer processed the friend removal request.
State changes after the call
- Local state merge: Remove the deleted contact from local friend lists using
userIDas the unique entity key. - Asynchronous event listening: Linked client devices and the former friend receive deletion notifications via
onFriendDeleted:inOIMFriendshipListener(see Retrieve the friend list by page). - Verification: To verify current friendship status, invoke Check friendship status.
Was this page helpful?