Browse SDKs · iOS
Platform
SDKsiOS

Reject a friend request

Reject a friend request with OpenIM iOS SDK.

Copy

Decline an incoming friend application using refuseFriendApplication:handleMsg:onSuccess:onFailure:.

Parameters

ParameterTypeRequiredDescription
userIDNSString *YesThe applicant user ID whose request is being rejected.
handleMsgNSString *NoOptional rejection note. Pass an empty string @"" when omitted.

Code example

[[OIMManager manager] refuseFriendApplication:applicantUserID
                                     handleMsg:@"Not adding contacts at this time"
                                     onSuccess:^(NSString *data) {
    [applicationStore markRejectedForUserID:applicantUserID];
}
                                     onFailure:^(NSInteger code, NSString *message) {
    NSLog(@"refuseFriendApplication failed: %ld %@", (long)code, message);
}];

Return value

The onSuccess callback confirms that OpenIMServer processed the rejection command.

State changes after the call

  • Local state merge: Merge rejection status into the application list using userID as the unique entity key.
  • Asynchronous event listening: Linked client devices and the applicant receive rejection notifications via onFriendApplicationRejected: in OIMFriendshipListener (see Retrieve received friend requests).