Browse SDKs · iOS
Platform
SDKsiOS

Delete a friend

Delete an iOS friend relationship.

Copy

Remove a friendship relationship between the authenticated user and a target contact using deleteFriend:onSuccess:onFailure:.

Parameters

ParameterTypeRequiredDescription
friendUserIDNSString *YesTarget 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 userID as the unique entity key.
  • Asynchronous event listening: Linked client devices and the former friend receive deletion notifications via onFriendDeleted: in OIMFriendshipListener (see Retrieve the friend list by page).
  • Verification: To verify current friendship status, invoke Check friendship status.