Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: 'Accept a call'
description: 'Accept a call invitation with OpenIM React Native SDK.'
product: 'sdk'
context: 'chat/sdk/react-native'
template: 'guide'
status: 'draft'
version: 'v4'
platform: 'react-native'
sourcePath: '/sdk/react-native/calling/managing-calls/accept-call'
---

After receiving `OnReceiveNewInvitation`, call `signalingAccept()` to accept the call invitation.

```ts
const roomCredentials = await OpenIMSDK.signalingAccept({
opUserID: currentUserID,
invitation,
});
```

`opUserID` is the user ID of the user accepting the invitation. Use the complete `invitation` object provided by the `OnReceiveNewInvitation` event callback.

The call returns `RtcInviteResults`, which contains the call room's `roomID`, `token`, and `liveURL`. Other participants receive the acceptance through `OnInviteeAccepted`; use `invitation.roomID` in its callback to identify the call. For event listeners, see [Handle call events](/sdk/react-native/calling/managing-calls/handle-call-events).
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: 'Cancel a call invitation'
description: 'Cancel a call invitation with OpenIM React Native SDK.'
product: 'sdk'
context: 'chat/sdk/react-native'
template: 'guide'
status: 'draft'
version: 'v4'
platform: 'react-native'
sourcePath: '/sdk/react-native/calling/managing-calls/cancel-call'
---

Before the call connects, the inviter can call `signalingCancel()` to cancel the invitation.

```ts
await OpenIMSDK.signalingCancel({
opUserID: currentUserID,
invitation,
});
```

`opUserID` is the user ID that cancels the invitation. Use the complete `RtcInvite` object saved when the call was initiated for `invitation`.

After the call returns, the cancellation request is complete. Invitees receive the cancellation through `OnInvitationCancelled`; use `invitation.roomID` in its callback to identify the call. For event parameters and listeners, see [Handle call events](/sdk/react-native/calling/managing-calls/handle-call-events).
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
title: 'Handle call events'
description: 'Listen for call events with OpenIM React Native SDK.'
product: 'sdk'
context: 'chat/sdk/react-native'
template: 'guide'
status: 'draft'
version: 'v4'
platform: 'react-native'
sourcePath: '/sdk/react-native/calling/managing-calls/handle-call-events'
---

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](/sdk/react-native/calling/sending-custom-signals/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.

```ts
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: 'Hang up a call'
description: 'Hang up a call with OpenIM React Native SDK.'
product: 'sdk'
context: 'chat/sdk/react-native'
template: 'guide'
status: 'draft'
version: 'v4'
platform: 'react-native'
sourcePath: '/sdk/react-native/calling/managing-calls/hang-up-call'
---

After a call connects, call `signalingHungUp()` to hang up.

```ts
await OpenIMSDK.signalingHungUp({
opUserID: currentUserID,
invitation,
});
```

`opUserID` is the user ID hanging up the call. Use the complete `RtcInvite` object for the current call for `invitation`; its `roomID` must match the active call room.

After the call returns, the hang-up request is complete. Other participants receive call-end information through `OnHangUp`; use `invitation.roomID` in its callback to identify the call. For event parameters and listeners, see [Handle call events](/sdk/react-native/calling/managing-calls/handle-call-events).
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: 'Reject a call'
description: 'Reject a call invitation with OpenIM React Native SDK.'
product: 'sdk'
context: 'chat/sdk/react-native'
template: 'guide'
status: 'draft'
version: 'v4'
platform: 'react-native'
sourcePath: '/sdk/react-native/calling/managing-calls/reject-call'
---

After receiving a call invitation, call `signalingReject()` to reject it when the invitation will not be accepted.

```ts
await OpenIMSDK.signalingReject({
opUserID: currentUserID,
invitation,
});
```

`opUserID` is the user ID of the user rejecting the invitation. Use the complete `invitation` object provided by the `OnReceiveNewInvitation` event callback.

After the call returns, the rejection request is complete. The inviter receives the result through `OnInviteeRejected`; use `invitation.roomID` in its callback to identify the call. For event parameters and listeners, see [Handle call events](/sdk/react-native/calling/managing-calls/handle-call-events).
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: 'Start a group call'
description: 'Start a group audio or video call with OpenIM React Native SDK.'
product: 'sdk'
context: 'chat/sdk/react-native'
template: 'guide'
status: 'draft'
version: 'v4'
platform: 'react-native'
sourcePath: '/sdk/react-native/calling/managing-calls/start-group-call'
---

Call `signalingInviteInGroup()` to start a group audio or video call. `groupID` identifies the group where the call starts. `inviteeUserIDList` specifies the members to invite; it does not automatically invite every group member.

```ts
const roomCredentials = await OpenIMSDK.signalingInviteInGroup({
invitation: {
inviterUserID: currentUserID,
inviteeUserIDList: memberUserIDs,
groupID,
roomID,
timeout: 30,
mediaType: 'video',
sessionType: SessionType.Group,
platformID: currentPlatform,
},
});
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `invitation` | `RtcInvite` | Yes | The call invitation. |
| `invitation.inviterUserID` | `string` | Yes | User ID of the user starting the call. |
| `invitation.inviteeUserIDList` | `string[]` | Yes | User IDs of the group members to invite. |
| `invitation.groupID` | `string` | Yes | Target group ID. |
| `invitation.roomID` | `string` | Yes | Room ID for this group call. |
| `invitation.timeout` | `number` | Yes | Invitation timeout in seconds. |
| `invitation.mediaType` | `string` | Yes | Media type, such as `audio` or `video`. |
| `invitation.sessionType` | `SessionType` | Yes | Pass `SessionType.Group` for a group call. |
| `invitation.platformID` | `Platform` | Yes | Inviter platform. Pass the `Platform` enum value for the current client. |
| `invitation.customData` | `string` | No | Application-defined extension string sent with the invitation. |
| `invitation.initiateTime` | `number` | No | Invitation start time as a Unix timestamp in milliseconds. It is usually managed by the calling flow and does not need to be set manually. |
| `invitation.busyLineUserIDList` | `string[]` | No | Busy-user list. It is usually omitted when starting a new invitation. |
| `offlinePushInfo` | `OfflinePush` | No | Push content for invited users when they are offline. |
| `offlinePushInfo.title` | `string` | Conditional | Push title when `offlinePushInfo` is provided. |
| `offlinePushInfo.desc` | `string` | Conditional | Push body when `offlinePushInfo` is provided. |
| `offlinePushInfo.ex` | `string` | Conditional | Extension string when `offlinePushInfo` is provided. Pass an empty string when there is no content. |
| `offlinePushInfo.iOSPushSound` | `string` | Conditional | iOS push sound when `offlinePushInfo` is provided. |
| `offlinePushInfo.iOSBadgeCount` | `boolean` | Conditional | Whether to update the iOS badge when `offlinePushInfo` is provided. |

The call returns `RtcInviteResults`, which includes `roomID`, `token`, `liveURL`, and an optional `busyLineUserIDList`. For field descriptions, see [Start a one-to-one call](/sdk/react-native/calling/managing-calls/start-single-call).

Invited members receive `OnReceiveNewInvitation` with `OnReceiveNewInvitationPayload`. For member acceptance, rejection, and room-leave status, see [Handle call events](/sdk/react-native/calling/managing-calls/handle-call-events).
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: 'Start a one-to-one call'
description: 'Start a one-to-one audio or video call with OpenIM React Native SDK.'
product: 'sdk'
context: 'chat/sdk/react-native'
template: 'guide'
status: 'draft'
version: 'v4'
platform: 'react-native'
sourcePath: '/sdk/react-native/calling/managing-calls/start-single-call'
---

Call `signalingInvite()` to start a one-to-one audio or video call. The call returns room credentials that the app can use to connect a real-time audio and video media engine with `roomID`, `token`, and `liveURL`.

```ts
const roomCredentials = await OpenIMSDK.signalingInvite({
invitation: {
inviterUserID: currentUserID,
inviteeUserIDList: [peerUserID],
groupID: '',
roomID,
timeout: 30,
mediaType: 'video',
sessionType: SessionType.Single,
platformID: currentPlatform,
},
});
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `invitation` | `RtcInvite` | Yes | The call invitation. |
| `invitation.inviterUserID` | `string` | Yes | User ID of the user starting the call. |
| `invitation.inviteeUserIDList` | `string[]` | Yes | Invited user IDs. For a one-to-one call, provide the other user's ID. |
| `invitation.groupID` | `string` | Yes | Pass an empty string for a one-to-one call. |
| `invitation.roomID` | `string` | Yes | Room ID for this call. Subsequent call operations and state handling use this value to identify the call. |
| `invitation.timeout` | `number` | Yes | Invitation timeout in seconds. |
| `invitation.mediaType` | `string` | Yes | Media type, such as `audio` or `video`. |
| `invitation.sessionType` | `SessionType` | Yes | Pass `SessionType.Single` for a one-to-one call. |
| `invitation.platformID` | `Platform` | Yes | Inviter platform. Pass the `Platform` enum value for the current client. |
| `invitation.customData` | `string` | No | Application-defined extension string sent with the invitation. |
| `invitation.initiateTime` | `number` | No | Invitation start time as a Unix timestamp in milliseconds. It is usually managed by the calling flow and does not need to be set manually. |
| `invitation.busyLineUserIDList` | `string[]` | No | Busy-user list. It is usually omitted when starting a new invitation. |
| `offlinePushInfo` | `OfflinePush` | No | Push content for invited users when they are offline. |
| `offlinePushInfo.title` | `string` | Conditional | Push title when `offlinePushInfo` is provided. |
| `offlinePushInfo.desc` | `string` | Conditional | Push body when `offlinePushInfo` is provided. |
| `offlinePushInfo.ex` | `string` | Conditional | Extension string when `offlinePushInfo` is provided. Pass an empty string when there is no content. |
| `offlinePushInfo.iOSPushSound` | `string` | Conditional | iOS push sound when `offlinePushInfo` is provided. |
| `offlinePushInfo.iOSBadgeCount` | `boolean` | Conditional | Whether to update the iOS badge when `offlinePushInfo` is provided. |

## Return value

The call returns `RtcInviteResults`:

| Field | Type | Description |
| --- | --- | --- |
| `roomID` | `string` | Call room ID. |
| `token` | `string` | Credential for joining the call room. |
| `liveURL` | `string` | Room address returned by the calling service. |
| `busyLineUserIDList` | `string[]` | IDs of invited users that are currently busy. |

The invitee receives `OnReceiveNewInvitation` with `OnReceiveNewInvitationPayload`. For acceptance, rejection, cancellation, and hang-up events, see [Handle call events](/sdk/react-native/calling/managing-calls/handle-call-events).
Loading