SDKsiOS
Accept a friend request
Accept a friend request with OpenIM iOS SDK.
Accept a friend request from an applicant to establish mutual friendship using acceptFriendApplication:handleMsg:onSuccess:onFailure:.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userID | NSString * | Yes | The applicant user ID who initiated the friend request. |
handleMsg | NSString * | No | Optional acceptance note (e.g., @"Accepted"). Pass an empty string @"" when omitted. |
Code example
[[OIMManager manager] acceptFriendApplication:applicantUserID
handleMsg:@"Accepted"
onSuccess:^(NSString *data) {
[applicationStore markAcceptedForUserID:applicantUserID];
}
onFailure:^(NSInteger code, NSString *message) {
NSLog(@"acceptFriendApplication failed: %ld %@", (long)code, message);
}];Return value
The onSuccess callback signifies that OpenIMServer processed the acceptance and established mutual friendship on the server.
State changes after the call
- Local state merge: Merge application resolution state using
userIDas the unique entity key. - Application updates: The application record updates via
onFriendApplicationAccepted:inOIMFriendshipListener(see Retrieve received friend requests). - Friend addition: The new friendship record arrives via
onFriendAdded:inOIMFriendshipListener(see Retrieve the friend list by page), where the client merges the new contact byuserID.
Was this page helpful?