SDKsReact NativeEnterprise
Handle call events
Listen for call events with OpenIM React Native SDK.
Call events report invitation status, participant status, and media-stream status. For invitation events, read room information from invitation in the callback parameter. Media-stream events provide roomID directly. To send and receive custom signals, see Send a custom signal.
Event parameters
| Event | Callback parameter type | Common fields |
|---|---|---|
OnReceiveNewInvitation | OnReceiveNewInvitationPayload | invitation, userID, participant, offlinePushInfo. |
OnInviteeAccepted | OnInviteeAcceptedPayload | invitation, userID, participant, opUserPlatformID. |
OnInviteeRejected | OnInviteeRejectedPayload | invitation, userID, participant, opUserPlatformID. |
OnInvitationCancelled | OnInvitationCancelledPayload | invitation, userID, participant, offlinePushInfo. |
OnInvitationTimeout | OnReceiveNewInvitationPayload | invitation, userID, participant, offlinePushInfo. |
OnInviteeAcceptedByOtherDevice | OnInviteeAcceptedPayload | invitation, userID, participant, opUserPlatformID. |
OnInviteeRejectedByOtherDevice | OnInviteeRejectedPayload | invitation, userID, participant, opUserPlatformID. |
OnHangUp | OnHangUpPayload | invitation, userID, offlinePushInfo. |
OnRoomParticipantConnected | OnRoomParticipantConnectedPayload | invitation, groupID, participant. |
OnRoomParticipantDisconnected | OnRoomParticipantDisconnectedPayload | invitation, groupID, participant. |
OnStreamChange | OnStreamChangePayload | roomID, streamType, mute. |
Use invitation.roomID or roomID to distinguish calls. Use participant.userInfo.userID to distinguish participants.
function handleReceiveNewInvitation(payload: OnReceiveNewInvitationPayload) {
// ...
}
function handleInviteeAccepted(payload: OnInviteeAcceptedPayload) {
// ...
}
function handleInviteeRejected(payload: OnInviteeRejectedPayload) {
// ...
}
function handleInvitationCancelled(payload: OnInvitationCancelledPayload) {
// ...
}
function handleInvitationTimeout(payload: OnReceiveNewInvitationPayload) {
// ...
}
function handleInviteeAcceptedByOtherDevice(payload: OnInviteeAcceptedPayload) {
// ...
}
function handleInviteeRejectedByOtherDevice(payload: OnInviteeRejectedPayload) {
// ...
}
function handleHangUp(payload: OnHangUpPayload) {
// ...
}
function handleRoomParticipantConnected(
payload: OnRoomParticipantConnectedPayload,
) {
// ...
}
function handleRoomParticipantDisconnected(
payload: OnRoomParticipantDisconnectedPayload,
) {
// ...
}
function handleStreamChange(payload: OnStreamChangePayload) {
// ...
}
// Start listening
OpenIMSDK.on(OpenIMEvent.OnReceiveNewInvitation, handleReceiveNewInvitation);
OpenIMSDK.on(OpenIMEvent.OnInviteeAccepted, handleInviteeAccepted);
OpenIMSDK.on(OpenIMEvent.OnInviteeRejected, handleInviteeRejected);
OpenIMSDK.on(OpenIMEvent.OnInvitationCancelled, handleInvitationCancelled);
OpenIMSDK.on(OpenIMEvent.OnInvitationTimeout, handleInvitationTimeout);
OpenIMSDK.on(
OpenIMEvent.OnInviteeAcceptedByOtherDevice,
handleInviteeAcceptedByOtherDevice,
);
OpenIMSDK.on(
OpenIMEvent.OnInviteeRejectedByOtherDevice,
handleInviteeRejectedByOtherDevice,
);
OpenIMSDK.on(OpenIMEvent.OnHangUp, handleHangUp);
OpenIMSDK.on(
OpenIMEvent.OnRoomParticipantConnected,
handleRoomParticipantConnected,
);
OpenIMSDK.on(
OpenIMEvent.OnRoomParticipantDisconnected,
handleRoomParticipantDisconnected,
);
OpenIMSDK.on(OpenIMEvent.OnStreamChange, handleStreamChange);
// Stop listening
OpenIMSDK.off(OpenIMEvent.OnReceiveNewInvitation, handleReceiveNewInvitation);
OpenIMSDK.off(OpenIMEvent.OnInviteeAccepted, handleInviteeAccepted);
OpenIMSDK.off(OpenIMEvent.OnInviteeRejected, handleInviteeRejected);
OpenIMSDK.off(OpenIMEvent.OnInvitationCancelled, handleInvitationCancelled);
OpenIMSDK.off(OpenIMEvent.OnInvitationTimeout, handleInvitationTimeout);
OpenIMSDK.off(
OpenIMEvent.OnInviteeAcceptedByOtherDevice,
handleInviteeAcceptedByOtherDevice,
);
OpenIMSDK.off(
OpenIMEvent.OnInviteeRejectedByOtherDevice,
handleInviteeRejectedByOtherDevice,
);
OpenIMSDK.off(OpenIMEvent.OnHangUp, handleHangUp);
OpenIMSDK.off(
OpenIMEvent.OnRoomParticipantConnected,
handleRoomParticipantConnected,
);
OpenIMSDK.off(
OpenIMEvent.OnRoomParticipantDisconnected,
handleRoomParticipantDisconnected,
);
OpenIMSDK.off(OpenIMEvent.OnStreamChange, handleStreamChange);Stop listening when the component is unmounted, the user signs out, or the account changes.
Was this page helpful?