This module provides VoIP call control functions for peripherals such as third-party wearables, including answering, rejecting, and ending incoming calls. The system selects the VoIP call to be controlled. Therefore, you do not need to specify the call ID.
Since: 26.0.1
Enumerates the video states when a VoIP call is answered.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Telephony.VoipCallManager
Since: 26.0.1
| Name | Value | Description |
|---|---|---|
| TYPE_VOICE | 0 | Voice state. |
| TYPE_VIDEO | 1 | Video state. |
answerCall(videoState?: VideoStateType): Promise<void>
Answers the current VoIP incoming call. The system selects the incoming call to be answered. Therefore, you do not need to specify the call ID. You can use the optional parameter videoState to distinguish between voice answering and video answering. If this parameter is not passed, voice answering is used by default. This API uses a promise to return the result.
Required permissions: ohos.permission.MANAGE_CALL_FOR_DEVICES
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Telephony.VoipCallManager
Since: 26.0.1
Parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| videoState | VideoStateType | No | Video state for answering a VoIP call. The value TYPE_VOICE indicates that the call is answered in voice mode, and TYPE_VIDEO indicates that the call is answered in video mode. The default value is TYPE_VOICE. |
Returns
| Type | Description |
|---|---|
| Promise<void> | Promise that returns no value. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
| ID | Error Message |
|---|---|
| 201 | Permission verification failed. The application does not have the permission required to call the API. |
| 1007200002 | Operation failed. Cannot connect to service. |
| 1007200003 | System internal error. |
| 1007200004 | No VoIP call is available for control. |
| 1007200999 | Unknown error code. |
Example:
import { voipCallControl } from '@kit.CallServiceKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
// Answer an incoming call as a voice call.
voipCallControl.answerCall().then(() => {
hilog.info(0x0000, 'testTag', 'Succeeded in answering the voice call.');
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'Failed to answer the voice call: %{public}d %{public}s', err.code, err.message);
});
// Answer an incoming call as a video call.
voipCallControl.answerCall(voipCallControl.VideoStateType.TYPE_VIDEO).then(() => {
hilog.info(0x0000, 'testTag', 'Succeeded in answering the video call.');
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'Failed to answer the video call: %{public}d %{public}s', err.code, err.message);
}); rejectCall(): Promise<void>
Rejects the current VoIP incoming call. The system selects the incoming call to be rejected. Therefore, you do not need to specify the call ID. This API uses a promise to return the result.
Required permissions: ohos.permission.MANAGE_CALL_FOR_DEVICES
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Telephony.VoipCallManager
Since: 26.0.1
Returns
| Type | Description |
|---|---|
| Promise<void> | Promise that returns no value. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
| ID | Error Message |
|---|---|
| 201 | Permission verification failed. The application does not have the permission required to call the API. |
| 1007200002 | Operation failed. Cannot connect to service. |
| 1007200003 | System internal error. |
| 1007200004 | No VoIP call is available for control. |
| 1007200999 | Unknown error code. |
Example:
import { voipCallControl } from '@kit.CallServiceKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
// Reject an incoming call.
voipCallControl.rejectCall().then(() => {
hilog.info(0x0000, 'testTag', 'Succeeded in rejecting the call.');
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'Failed to reject the call: %{public}d %{public}s', err.code, err.message);
}); hangUpCall(): Promise<void>
Ends the current VoIP call. The system selects the call to be ended. The active call is ended first. If there is no active call in the incoming call, the incoming call is ended. This API uses a promise to return the result.
Required permissions: ohos.permission.MANAGE_CALL_FOR_DEVICES
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Telephony.VoipCallManager
Since: 26.0.1
Returns
| Type | Description |
|---|---|
| Promise<void> | Promise that returns no value. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
| ID | Error Message |
|---|---|
| 201 | Permission verification failed. The application does not have the permission required to call the API. |
| 1007200002 | Operation failed. Cannot connect to service. |
| 1007200003 | System internal error. |
| 1007200004 | No VoIP call is available for control. |
| 1007200999 | Unknown error code. |
Example:
import { voipCallControl } from '@kit.CallServiceKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
// End the current call.
voipCallControl.hangUpCall().then(() => {
hilog.info(0x0000, 'testTag', 'Succeeded in hanging up the call.');
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'Failed to hang up the call: %{public}d %{public}s', err.code, err.message);
});