Browse SDKs · React Native
Platform
SDKsReact NativeIncludes Enterprise features

Get received friend applications

Paginate and retrieve incoming friend requests by status using the OpenIM React Native SDK.

Copy

Paginate and query friend applications received by the authenticated user filtered by handling status:

const applications = await OpenIMSDK.getFriendApplicationListAsRecipient({
  handleResults: [ApplicationHandleResult.Unprocessed],
  offset: 0,
  count: 20,
});

Parameters

ParameterTypeRequiredDescription
handleResultsnumber[]YesList of application statuses to filter by.
offsetnumberYesPagination offset starting from 0.
countnumberYesMaximum number of records to fetch per batch.

Status enum values:

Enum valueValueDescription
ApplicationHandleResult.Unprocessed0Pending review.
ApplicationHandleResult.Agree1Approved.
ApplicationHandleResult.Reject-1Rejected.

Return value

Resolves to an array of FriendApplicationItem[] for the requested page.

Friend application properties

Key properties in FriendApplicationItem:

FieldTypeDescription
fromUserIDstringUser ID of the applicant.
fromNicknamestringNickname of the applicant.
fromFaceURLstringAvatar URL of the applicant.
toUserIDstringUser ID of the recipient (the current user).
toNicknamestringNickname of the recipient.
toFaceURLstringAvatar URL of the recipient.
reqMsgstringGreeting message attached to the request.
handleResultApplicationHandleResultCurrent handling status.
handlerUserIDstringUser ID who processed the application.
handleMsgstringResponse note provided when processing.
handleTimenumberProcessing timestamp in Unix milliseconds.
createTimenumberRequest creation timestamp in Unix milliseconds.
exstringCustom extension string.

Listen for friend application changes

Friend application events trigger OnFriendApplicationAdded, OnFriendApplicationAccepted, OnFriendApplicationRejected, or OnFriendApplicationDeletedEnterprise, delivering the affected FriendApplicationItem:

const handleApplicationChanged = (application: FriendApplicationItem) => {
  // Update state using composite key fromUserID and toUserID
};

const handleApplicationDeleted = (application: FriendApplicationItem) => {
  // Remove application matching fromUserID and toUserID
};

// Register listeners
OpenIMSDK.on(OpenIMEvent.OnFriendApplicationAdded, handleApplicationChanged);
OpenIMSDK.on(OpenIMEvent.OnFriendApplicationAccepted, handleApplicationChanged);
OpenIMSDK.on(OpenIMEvent.OnFriendApplicationRejected, handleApplicationChanged);
OpenIMSDK.on(OpenIMEvent.OnFriendApplicationDeleted, handleApplicationDeleted);

// Remove listeners
OpenIMSDK.off(OpenIMEvent.OnFriendApplicationAdded, handleApplicationChanged);
OpenIMSDK.off(OpenIMEvent.OnFriendApplicationAccepted, handleApplicationChanged);
OpenIMSDK.off(OpenIMEvent.OnFriendApplicationRejected, handleApplicationChanged);
OpenIMSDK.off(OpenIMEvent.OnFriendApplicationDeleted, handleApplicationDeleted);

Identify individual application entries using the composite key fromUserID:toUserID. Unregister listeners when the view unmounts, the user signs out, or accounts switch.