js-apis-call.md 21.4 KB
Newer Older
S
shawn_he 已提交
1 2
# Call

S
shawn_he 已提交
3
>**NOTE**
S
shawn_he 已提交
4
>
Z
zengyawen 已提交
5
>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
S
shawn_he 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19


## Modules to Import

```
import call from '@ohos.telephony.call';
```

## call.dial<a name=call.dial-callback1></a>

dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void

Initiates a call. This function uses an asynchronous callback to return the execution result.

S
shawn_he 已提交
20 21 22
**Required permission**: ohos.permission.PLACE\_CALL (a system permission)

**System capability**: SystemCapability.Telephony.CallManager
S
shawn_he 已提交
23

S
shawn_he 已提交
24
**Parameters**
S
shawn_he 已提交
25

S
shawn_he 已提交
26
| Name       | Type                        | Mandatory| Description                                             |
S
shawn_he 已提交
27
| ----------- | ---------------------------- | ---- | ------------------------------------------------- |
S
shawn_he 已提交
28 29
| phoneNumber | string                       | Yes  | Phone number.                                       |
| callback    | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.<br>- **true**: success<br>- **false**: failure|
S
shawn_he 已提交
30 31 32 33 34 35 36 37

**Example**

```
call.dial("138xxxxxxxx", (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
38 39 40 41 42 43 44 45


## call.dial<a name=call.dial-callback2></a>

dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean\>\): void

Initiates a call. You can set call options as needed. This function uses an asynchronous callback to return the execution result.

S
shawn_he 已提交
46 47 48
**Required permission**: ohos.permission.PLACE\_CALL (a system permission)

**System capability**: SystemCapability.Telephony.CallManager
S
shawn_he 已提交
49

S
shawn_he 已提交
50
**Parameters**
S
shawn_he 已提交
51

S
shawn_he 已提交
52
| Name       | Type                        | Mandatory| Description                                             |
S
shawn_he 已提交
53
| ----------- | ---------------------------- | ---- | ------------------------------------------------- |
S
shawn_he 已提交
54 55 56
| phoneNumber | string                       | Yes  | Phone number.                                       |
| options     | DialOptions                  | Yes  | Call options. For details, see [DialOptions](#DialOptions).      |
| callback    | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.<br>- **true**: success<br>- **false**: failure|
S
shawn_he 已提交
57

S
shawn_he 已提交
58
**Example**
S
shawn_he 已提交
59

S
shawn_he 已提交
60 61 62 63 64 65 66
```
call.dial("138xxxxxxxx", {
    extras: false
}, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
67 68 69 70 71 72 73 74


## call.dial<a name=call.dial-promise></a>

dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\>

Initiates a call. You can set call options as needed. This function uses a promise to return the execution result.

S
shawn_he 已提交
75 76 77
**Required permission**: ohos.permission.PLACE\_CALL (a system permission)

**System capability**: SystemCapability.Telephony.CallManager
S
shawn_he 已提交
78

S
shawn_he 已提交
79
**Parameters**
S
shawn_he 已提交
80

S
shawn_he 已提交
81
| Name       | Type       | Mandatory| Description                                       |
S
shawn_he 已提交
82
| ----------- | ----------- | ---- | ------------------------------------------- |
S
shawn_he 已提交
83 84
| phoneNumber | string      | Yes  | Phone number.                                 |
| options     | DialOptions | Yes  | Call options. For details, see [DialOptions](#DialOptions).|
S
shawn_he 已提交
85

S
shawn_he 已提交
86
**Return Value**
S
shawn_he 已提交
87

S
shawn_he 已提交
88
| Type                  | Description                             |
S
shawn_he 已提交
89 90
| ---------------------- | --------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
S
shawn_he 已提交
91

S
shawn_he 已提交
92
**Example**
S
shawn_he 已提交
93

S
shawn_he 已提交
94 95 96 97 98 99 100 101 102 103
```
let promise = call.dial("138xxxxxxxx", {
    extras: false
});
promise.then(data => {
    console.log(`dial success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.error(`dial fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
104

S
shawn_he 已提交
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
## call.makeCall<sup>7+</sup><a name=call.makeCall-callback></a>

makeCall(phoneNumber: string, callback: AsyncCallback<void>): void

Launches the call screen and displays the dialed number. This method uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Telephony.CallManager

**Parameters**

| Name       | Type                     | Mandatory| Description                                      |
| ----------- | ------------------------- | ---- | ------------------------------------------ |
| phoneNumber | string                    | Yes  | Phone number.                                |
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|

**Example**

```
call.makeCall("138xxxxxxxx", err => { 
    console.log(`makeCall callback: err->${JSON.stringify(err)}`); 
});
```


## call.makeCall<sup>7+</sup><a name=call.makeCall-promise></a>

makeCall(phoneNumber: string): Promise<void>

Launches the call screen and displays the dialed number. This method uses a promise to return the result.

**System capability**: SystemCapability.Telephony.CallManager

**Parameters**

| Name       | Type  | Mandatory| Description      |
| ----------- | ------ | ---- | ---------- |
| phoneNumber | string | Yes  | Phone number.|

**Return Value**

| Type               | Description                             |
| ------------------- | --------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|

**Example**

```
let promise = call.makeCall("138xxxxxxxx"); 
promise.then(() => { 
    console.log(`makeCall success`); 
}).catch(err => { 
    console.error(`makeCall fail, promise: err->${JSON.stringify(err)}`); 
});
```

S
shawn_he 已提交
160 161 162 163 164 165
## call.hasCall<a name=call.hasCall-callback></a>

hasCall\(callback: AsyncCallback<boolean\>\): void

Checks whether a call is in progress. This function uses an asynchronous callback to return the result.

S
shawn_he 已提交
166 167
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
168
**Parameters**
S
shawn_he 已提交
169

S
shawn_he 已提交
170
| Name    | Type                        | Mandatory| Description                                                        |
S
shawn_he 已提交
171
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
172
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.<br>- **true**: A call is in progress.<br>- **false**: No call is in progress.|
S
shawn_he 已提交
173

S
shawn_he 已提交
174
**Example**
S
shawn_he 已提交
175

S
shawn_he 已提交
176 177 178 179 180
```
call.hasCall((err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
181 182 183 184 185 186 187 188


## call.hasCall<a name=call.hasCall-promise></a>

hasCall\(\): Promise<boolean\>

Checks whether a call is in progress. This function uses a promise to return the result.

S
shawn_he 已提交
189 190
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
191
**Return Value**
S
shawn_he 已提交
192

S
shawn_he 已提交
193
| Type                  | Description                                   |
S
shawn_he 已提交
194 195
| ---------------------- | --------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
S
shawn_he 已提交
196

S
shawn_he 已提交
197
**Example**
S
shawn_he 已提交
198

S
shawn_he 已提交
199 200 201 202 203 204 205 206
```
let promise = call.hasCall();
promise.then(data => {
    console.log(`hasCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.error(`hasCall fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
207 208 209 210 211 212 213 214


## call.getCallState<a name=call.getCallState-callback></a>

getCallState\(callback: AsyncCallback<CallState\>\): void

Obtains the call status. This function uses an asynchronous callback to return the result.

S
shawn_he 已提交
215 216
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
217
**Parameters**
S
shawn_he 已提交
218

S
shawn_he 已提交
219
| Name    | Type                                        | Mandatory| Description                                |
S
shawn_he 已提交
220
| -------- | -------------------------------------------- | ---- | ------------------------------------ |
S
shawn_he 已提交
221
| callback | AsyncCallback&lt;[CallState](#CallState)&gt; | Yes  | Callback used to return the result.|
S
shawn_he 已提交
222

S
shawn_he 已提交
223
**Example**
S
shawn_he 已提交
224

S
shawn_he 已提交
225 226 227 228 229
```
call.getCallState((err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
230 231 232 233 234 235 236 237


## call.getCallState<a name="call.getCallState-promise"></a>

getCallState\(\): Promise<CallState\>

Obtains the call status. This function uses a promise to return the result.

S
shawn_he 已提交
238 239
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
240
**Return Value**
S
shawn_he 已提交
241

S
shawn_he 已提交
242
| Type                                  | Description                                     |
S
shawn_he 已提交
243 244
| -------------------------------------- | ----------------------------------------- |
| Promise&lt;[CallState](#CallState)&gt; | Promise used to return the result.|
S
shawn_he 已提交
245

S
shawn_he 已提交
246
**Example**
S
shawn_he 已提交
247

S
shawn_he 已提交
248 249 250 251 252 253 254 255
```
let promise = call.getCallState();
promise.then(data => {
    console.log(`getCallState success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.error(`getCallState fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
256

S
shawn_he 已提交
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
## call.hasVoiceCapability<sup>7+</sup><a name=call.hasVoiceCapability></a>

hasVoiceCapability(): boolean

Checks whether a device supports voice calls. This function works in synchronous mode.

**System capability**: SystemCapability.Telephony.CallManager

**Return Value**

| Type   | Description                                                        |
| ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device supports voice calls.<br>- **false**: The device does not support voice calls.|

```
let result = call.hasVoiceCapability(); 
console.log(`hasVoiceCapability: ${JSON.stringify(result)}`);
```

S
shawn_he 已提交
276 277 278 279
## call.isEmergencyPhoneNumber<sup>7+</sup><a name=call.isEmergencyPhoneNumber-callback1></a>

isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void

S
shawn_he 已提交
280
Checks whether the call number of the SIM card in the specified slot is an emergency number. This function uses an asynchronous callback to return the result.
S
shawn_he 已提交
281

S
shawn_he 已提交
282 283
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
284
**Parameters**
S
shawn_he 已提交
285

S
shawn_he 已提交
286
| Name       | Type                        | Mandatory| Description                                                        |
S
shawn_he 已提交
287
| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
288 289
| phoneNumber | string                       | Yes  | Phone number.                                                  |
| callback    | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.<br>- **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number.|
S
shawn_he 已提交
290

S
shawn_he 已提交
291
**Example**
S
shawn_he 已提交
292

S
shawn_he 已提交
293 294 295 296 297
```
call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
298 299 300 301 302 303


## call.isEmergencyPhoneNumber<sup>7+</sup><a name=call.isEmergencyPhoneNumber-callback2></a>

isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback<boolean\>\): void

S
shawn_he 已提交
304
Checks whether the call number of the SIM card in the specified slot is an emergency number. This function uses an asynchronous callback to return the result.
S
shawn_he 已提交
305

S
shawn_he 已提交
306 307
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
308
**Parameters**
S
shawn_he 已提交
309

S
shawn_he 已提交
310
| Name       | Type                        | Mandatory| Description                                                        |
S
shawn_he 已提交
311
| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
312 313 314
| phoneNumber | string                       | Yes  | Phone number.                                                  |
| options     | EmergencyNumberOptions       | Yes  | Emergency number options defined in [EmergencyNumberOptions](#EmergencyNumberOptions).|
| callback    | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.<br>- **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number.|
S
shawn_he 已提交
315

S
shawn_he 已提交
316
**Example**
S
shawn_he 已提交
317

S
shawn_he 已提交
318 319 320 321 322
```
call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
323 324 325 326 327 328


## call.isEmergencyPhoneNumber<sup>7+</sup><a name=call.isEmergencyPhoneNumber-promise></a>

isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Promise<boolean\>

S
shawn_he 已提交
329
Checks whether the call number of the SIM card in the specified slot is an emergency number. This function uses a promise to return the result.
S
shawn_he 已提交
330

S
shawn_he 已提交
331 332
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
333
**Parameters**
S
shawn_he 已提交
334

S
shawn_he 已提交
335
| Name       | Type                  | Mandatory| Description                                                        |
S
shawn_he 已提交
336
| ----------- | ---------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
337 338
| phoneNumber | string                 | Yes  | Phone number.                                                  |
| options     | EmergencyNumberOptions | Yes  | Emergency number options defined in [EmergencyNumberOptions](#EmergencyNumberOptions).|
S
shawn_he 已提交
339

S
shawn_he 已提交
340
**Return Value**
S
shawn_he 已提交
341

S
shawn_he 已提交
342
| Type                  | Description                                               |
S
shawn_he 已提交
343 344
| ---------------------- | --------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
S
shawn_he 已提交
345

S
shawn_he 已提交
346
**Example**
S
shawn_he 已提交
347

S
shawn_he 已提交
348 349 350 351 352 353 354 355
```
let promise = call.isEmergencyPhoneNumber("138xxxxxxxx", {slotId: 1});
promise.then(data => {
    console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.error(`isEmergencyPhoneNumber fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
356 357 358 359 360

## call.formatPhoneNumber<sup>7+</sup><a name=call.formatPhoneNumber-callback1></a>

formatPhoneNumber\(phoneNumber: string, callback: AsyncCallback<string\>\): void

S
shawn_he 已提交
361
Formats a phone number based on the specified ISO country code. This function uses an asynchronous callback to return the result.
S
shawn_he 已提交
362

S
shawn_he 已提交
363 364
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
365
**Parameters**
S
shawn_he 已提交
366

S
shawn_he 已提交
367
| Name       | Type                       | Mandatory| Description                                |
S
shawn_he 已提交
368
| ----------- | --------------------------- | ---- | ------------------------------------ |
S
shawn_he 已提交
369 370
| phoneNumber | string                      | Yes  | Phone number.                          |
| callback    | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.|
S
shawn_he 已提交
371

S
shawn_he 已提交
372
**Example**
S
shawn_he 已提交
373

S
shawn_he 已提交
374 375 376 377 378
```
call.formatPhoneNumber("138xxxxxxxx", (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
379 380 381 382 383 384 385 386


## call.formatPhoneNumber<sup>7+</sup><a name=call.formatPhoneNumber-callback2></a>

formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback<string\>\): void

Formats a phone number based on specified formatting options. This function uses an asynchronous callback to return the result.

S
shawn_he 已提交
387 388
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
389
**Parameters**
S
shawn_he 已提交
390

S
shawn_he 已提交
391
| Name       | Type                       | Mandatory| Description                                                        |
S
shawn_he 已提交
392
| ----------- | --------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
393 394 395
| phoneNumber | string                      | Yes  | Phone number.                                                  |
| options     | NumberFormatOptions         | Yes  | Number formatting options defined in [NumberFormatOptions](#NumberFormatOptions).|
| callback    | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.                        |
S
shawn_he 已提交
396

S
shawn_he 已提交
397
**Example**
S
shawn_he 已提交
398

S
shawn_he 已提交
399 400 401 402 403 404 405
```
call.formatPhoneNumber("138xxxxxxxx",{
    countryCode: "CN"
}, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
406 407 408 409 410 411 412 413


## call.formatPhoneNumber<sup>7+</sup><a name=call.formatPhoneNumber-promise></a>

formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise<string\>

Formats a phone number based on specified formatting options. This function uses a promise to return the result.

S
shawn_he 已提交
414 415
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
416
**Parameters**
S
shawn_he 已提交
417

S
shawn_he 已提交
418
| Name       | Type               | Mandatory| Description                                                        |
S
shawn_he 已提交
419
| ----------- | ------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
420 421
| phoneNumber | string              | Yes  | Phone number.                                                  |
| options     | NumberFormatOptions | Yes  | Number formatting options defined in [NumberFormatOptions](#NumberFormatOptions).|
S
shawn_he 已提交
422

S
shawn_he 已提交
423
**Return Value**
S
shawn_he 已提交
424

S
shawn_he 已提交
425
| Type                 | Description                                       |
S
shawn_he 已提交
426 427
| --------------------- | ------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.|
S
shawn_he 已提交
428

S
shawn_he 已提交
429
**Example**
S
shawn_he 已提交
430

S
shawn_he 已提交
431 432 433 434 435 436 437 438 439 440
```
let promise = call.formatPhoneNumber("138xxxxxxxx", {
    countryCode: "CN"
});
promise.then(data => {
    console.log(`formatPhoneNumber success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.error(`formatPhoneNumber fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
441 442 443 444 445 446 447 448 449 450 451

## call.formatPhoneNumberToE164<sup>7+</sup><a name=call.formatPhoneNumberToE164-callback></a>

formatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: AsyncCallback<string\>\): void

Converts a phone number into the E.164 format. This function uses an asynchronous callback to return the result.

The phone number must match the specified country code. For example, for a China phone number, the country code must be **CN**. Otherwise, **null** will be returned.

All country codes are supported.

S
shawn_he 已提交
452 453
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
454
**Parameters**
S
shawn_he 已提交
455

S
shawn_he 已提交
456
| Name       | Type                       | Mandatory| Description                                                 |
S
shawn_he 已提交
457
| ----------- | --------------------------- | ---- | ----------------------------------------------------- |
S
shawn_he 已提交
458 459 460
| phoneNumber | string                      | Yes  | Phone number.                                           |
| countryCode | string                      | Yes  | Country code, for example, **CN** (China). All country codes are supported.             |
| callback    | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.|
S
shawn_he 已提交
461

S
shawn_he 已提交
462
**Example**
S
shawn_he 已提交
463

S
shawn_he 已提交
464 465 466 467 468 469 470
```
call.formatPhoneNumberToE164("138xxxxxxxx",{
    countryCode: "CN"
}, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
471 472 473 474 475 476 477 478 479 480 481 482


## call.formatPhoneNumberToE164<sup>7+</sup><a name=call.formatPhoneNumberToE164-promise></a>

formatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise<string\>

Converts a phone number into the E.164 format. This function uses a promise to return the result.

The phone number must match the specified country code. For example, for a China phone number, the country code must be **CN**. Otherwise, **null** will be returned.

All country codes are supported.

S
shawn_he 已提交
483 484
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
485
**Parameters**
S
shawn_he 已提交
486

S
shawn_he 已提交
487
| Name       | Type  | Mandatory| Description                                    |
S
shawn_he 已提交
488
| ----------- | ------ | ---- | ---------------------------------------- |
S
shawn_he 已提交
489 490
| phoneNumber | string | Yes  | Phone number.                              |
| countryCode | string | Yes  | Country code, for example, **CN** (China). All country codes are supported.|
S
shawn_he 已提交
491

S
shawn_he 已提交
492
**Return Value**
S
shawn_he 已提交
493

S
shawn_he 已提交
494
| Type                 | Description                                                        |
S
shawn_he 已提交
495 496
| --------------------- | ------------------------------------------------------------ |
| Promise&lt;string&gt; | Promise used to return the result.|
S
shawn_he 已提交
497

S
shawn_he 已提交
498
**Example**
S
shawn_he 已提交
499

S
shawn_he 已提交
500 501 502 503 504 505 506 507 508 509
```
let promise = call.formatPhoneNumberToE164("138xxxxxxxx", {
    countryCode: "CN"
});
promise.then(data => {
    console.log(`formatPhoneNumberToE164 success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.error(`formatPhoneNumberToE164 fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
510 511 512 513

## DialOptions<a name=DialOptions></a>

Provides an option for determining whether a call is a video call.
S
shawn_he 已提交
514 515 516

**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
517
| Parameter  | Type   | Mandatory| Description                                                        |
S
shawn_he 已提交
518
| ------ | ------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
519
| extras | boolean | No  | Indication of a video call. <br>- **true**: video call<br>- **false** (default): voice call|
S
shawn_he 已提交
520 521 522 523

## CallState<a name=CallState></a>

Enumerates call states.
S
shawn_he 已提交
524

S
shawn_he 已提交
525
| Variable              | Value  | Description                                                        |
S
shawn_he 已提交
526
| ------------------ | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
527 528 529 530
| CALL_STATE_UNKNOWN | -1   | The call status fails to be obtained and is unknown.<br>**System capability**: SystemCapability.Telephony.CallManager|
| CALL_STATE_IDLE    | 0    | No call is in progress.<br>**System capability**: SystemCapability.Telephony.CallManager|
| CALL_STATE_RINGING | 1    | The call is in the ringing or waiting state.<br>**System capability**: SystemCapability.Telephony.CallManager|
| CALL_STATE_OFFHOOK | 2    | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.<br>**System capability**: SystemCapability.Telephony.CallManager|
S
shawn_he 已提交
531 532 533 534

## EmergencyNumberOptions<sup>7+</sup><a name=EmergencyNumberOptions></a>

Provides an option for determining whether a number is an emergency number for the SIM card in the specified slot.
S
shawn_he 已提交
535 536 537

**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
538
| Parameter  | Type  | Mandatory| Description                                      |
S
shawn_he 已提交
539
| ------ | ------ | ---- | ------------------------------------------ |
S
shawn_he 已提交
540
| slotId | number | No  | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
541 542 543 544

## NumberFormatOptions<sup>7+</sup><a name=NumberFormatOptions></a>

Provides an option for number formatting.
S
shawn_he 已提交
545 546 547

**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
548
| Parameter       | Type  | Mandatory| Description                                                      |
S
shawn_he 已提交
549
| ----------- | ------ | ---- | ---------------------------------------------------------- |
S
shawn_he 已提交
550
| countryCode | string | No  | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.|