js-apis-call.md 20.5 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


## Modules to Import

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

S
shawn_he 已提交
14
## call.dial
S
shawn_he 已提交
15 16 17

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

S
shawn_he 已提交
18
Initiates a call. This API uses an asynchronous callback to return the execution result.
S
shawn_he 已提交
19

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


S
shawn_he 已提交
40
## call.dial
S
shawn_he 已提交
41 42 43

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

S
shawn_he 已提交
44
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the execution result.
S
shawn_he 已提交
45

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
| phoneNumber | string                       | Yes  | Phone number.                                       |
S
shawn_he 已提交
55
| options     | DialOptions                  | Yes  | Call options defined in [DialOptions](#dialoptions).      |
S
shawn_he 已提交
56
| 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


S
shawn_he 已提交
69
## call.dial
S
shawn_he 已提交
70 71 72

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

S
shawn_he 已提交
73
Initiates a call. You can set call options as needed. This API uses a promise to return the execution result.
S
shawn_he 已提交
74

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
| phoneNumber | string      | Yes  | Phone number.                                 |
S
shawn_he 已提交
84
| options     | DialOptions | Yes  | Call options defined in [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
## call.makeCall<sup>7+</sup>
S
shawn_he 已提交
106

S
shawn_he 已提交
107
makeCall(phoneNumber: string, callback: AsyncCallback\<void\>): void
S
shawn_he 已提交
108

S
shawn_he 已提交
109
Launches the call screen and displays the dialed number. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
110

S
shawn_he 已提交
111 112 113
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.Applications.Contacts
S
shawn_he 已提交
114 115 116

**Parameters**

S
shawn_he 已提交
117
| Name     | Type                     | Mandatory| Description                                      |
S
shawn_he 已提交
118 119 120 121 122 123 124 125 126 127 128 129 130
| ----------- | ------------------------- | ---- | ------------------------------------------ |
| 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)}`); 
});
```


S
shawn_he 已提交
131
## call.makeCall<sup>7+</sup>
S
shawn_he 已提交
132

S
shawn_he 已提交
133
makeCall(phoneNumber: string): Promise\<void\>
S
shawn_he 已提交
134

S
shawn_he 已提交
135
Launches the call screen and displays the dialed number. This API uses a promise to return the result.
S
shawn_he 已提交
136

S
shawn_he 已提交
137 138 139
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.Applications.Contacts
S
shawn_he 已提交
140 141 142

**Parameters**

S
shawn_he 已提交
143
| Name     | Type  | Mandatory| Description      |
S
shawn_he 已提交
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
| ----------- | ------ | ---- | ---------- |
| 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 已提交
164
## call.hasCall
S
shawn_he 已提交
165 166 167

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

S
shawn_he 已提交
168
Checks whether a call is in progress. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
169

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

S
shawn_he 已提交
172
**Parameters**
S
shawn_he 已提交
173

S
shawn_he 已提交
174
| Name  | Type                        | Mandatory| Description                                                        |
S
shawn_he 已提交
175
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
176
| 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 已提交
177

S
shawn_he 已提交
178
**Example**
S
shawn_he 已提交
179

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


S
shawn_he 已提交
187
## call.hasCall
S
shawn_he 已提交
188 189 190

hasCall\(\): Promise<boolean\>

S
shawn_he 已提交
191
Checks whether a call is in progress. This API uses a promise to return the result.
S
shawn_he 已提交
192

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

S
shawn_he 已提交
195
**Return Value**
S
shawn_he 已提交
196

S
shawn_he 已提交
197
| Type                  | Description                                   |
S
shawn_he 已提交
198 199
| ---------------------- | --------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
S
shawn_he 已提交
200

S
shawn_he 已提交
201
**Example**
S
shawn_he 已提交
202

S
shawn_he 已提交
203 204 205 206 207 208 209 210
```
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 已提交
211 212


S
shawn_he 已提交
213
## call.getCallState
S
shawn_he 已提交
214 215 216

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

S
shawn_he 已提交
217
Obtains the call status. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
218

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

S
shawn_he 已提交
221
**Parameters**
S
shawn_he 已提交
222

S
shawn_he 已提交
223
| Name  | Type                                        | Mandatory| Description                                |
S
shawn_he 已提交
224
| -------- | -------------------------------------------- | ---- | ------------------------------------ |
S
shawn_he 已提交
225
| callback | AsyncCallback&lt;[CallState](#callstate)&gt; | Yes  | Callback used to return the result.|
S
shawn_he 已提交
226

S
shawn_he 已提交
227
**Example**
S
shawn_he 已提交
228

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


S
shawn_he 已提交
236
## call.getCallState
S
shawn_he 已提交
237 238 239

getCallState\(\): Promise<CallState\>

S
shawn_he 已提交
240
Obtains the call status. This API uses a promise to return the result.
S
shawn_he 已提交
241

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

S
shawn_he 已提交
244
**Return Value**
S
shawn_he 已提交
245

S
shawn_he 已提交
246
| Type                                  | Description                                     |
S
shawn_he 已提交
247
| -------------------------------------- | ----------------------------------------- |
S
shawn_he 已提交
248
| Promise&lt;[CallState](#callstate)&gt; | Promise used to return the result.|
S
shawn_he 已提交
249

S
shawn_he 已提交
250
**Example**
S
shawn_he 已提交
251

S
shawn_he 已提交
252 253 254 255 256 257 258 259
```
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 已提交
260

S
shawn_he 已提交
261
## call.hasVoiceCapability<sup>7+</sup>
S
shawn_he 已提交
262 263 264

hasVoiceCapability(): boolean

S
shawn_he 已提交
265
Checks whether a device supports voice calls. This API works in synchronous mode.
S
shawn_he 已提交
266 267 268 269 270 271 272 273 274 275 276 277 278 279

**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 已提交
280
## call.isEmergencyPhoneNumber<sup>7+</sup>
S
shawn_he 已提交
281 282 283

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

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

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

S
shawn_he 已提交
288
**Parameters**
S
shawn_he 已提交
289

S
shawn_he 已提交
290
| Name     | Type                        | Mandatory| Description                                                        |
S
shawn_he 已提交
291
| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
292 293
| 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 已提交
294

S
shawn_he 已提交
295
**Example**
S
shawn_he 已提交
296

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


S
shawn_he 已提交
304
## call.isEmergencyPhoneNumber<sup>7+</sup>
S
shawn_he 已提交
305 306 307

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

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

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

S
shawn_he 已提交
312
**Parameters**
S
shawn_he 已提交
313

S
shawn_he 已提交
314
| Name     | Type                        | Mandatory| Description                                                        |
S
shawn_he 已提交
315
| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
316
| phoneNumber | string                       | Yes  | Phone number.                                                  |
S
shawn_he 已提交
317
| options     | EmergencyNumberOptions       | Yes  | Emergency number options defined in [EmergencyNumberOptions](#emergencynumberoptions7).|
S
shawn_he 已提交
318
| 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 已提交
319

S
shawn_he 已提交
320
**Example**
S
shawn_he 已提交
321

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


S
shawn_he 已提交
329
## call.isEmergencyPhoneNumber<sup>7+</sup>
S
shawn_he 已提交
330 331 332

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

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

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

S
shawn_he 已提交
337
**Parameters**
S
shawn_he 已提交
338

S
shawn_he 已提交
339
| Name     | Type                  | Mandatory| Description                                                        |
S
shawn_he 已提交
340
| ----------- | ---------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
341
| phoneNumber | string                 | Yes  | Phone number.                                                  |
S
shawn_he 已提交
342
| options     | EmergencyNumberOptions | Yes  | Emergency number options defined in [EmergencyNumberOptions](#emergencynumberoptions7).|
S
shawn_he 已提交
343

S
shawn_he 已提交
344
**Return Value**
S
shawn_he 已提交
345

S
shawn_he 已提交
346
| Type                  | Description                                               |
S
shawn_he 已提交
347 348
| ---------------------- | --------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
S
shawn_he 已提交
349

S
shawn_he 已提交
350
**Example**
S
shawn_he 已提交
351

S
shawn_he 已提交
352 353 354 355 356 357 358 359
```
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 已提交
360

S
shawn_he 已提交
361
## call.formatPhoneNumber<sup>7+</sup>
S
shawn_he 已提交
362 363 364

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

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

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

S
shawn_he 已提交
369
**Parameters**
S
shawn_he 已提交
370

S
shawn_he 已提交
371
| Name     | Type                       | Mandatory| Description                                |
S
shawn_he 已提交
372
| ----------- | --------------------------- | ---- | ------------------------------------ |
S
shawn_he 已提交
373 374
| phoneNumber | string                      | Yes  | Phone number.                          |
| callback    | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.|
S
shawn_he 已提交
375

S
shawn_he 已提交
376
**Example**
S
shawn_he 已提交
377

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


S
shawn_he 已提交
385
## call.formatPhoneNumber<sup>7+</sup>
S
shawn_he 已提交
386 387 388

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

S
shawn_he 已提交
389
Formats a phone number based on specified formatting options. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
390

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

S
shawn_he 已提交
393
**Parameters**
S
shawn_he 已提交
394

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

S
shawn_he 已提交
401
**Example**
S
shawn_he 已提交
402

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


S
shawn_he 已提交
412
## call.formatPhoneNumber<sup>7+</sup>
S
shawn_he 已提交
413 414 415

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

S
shawn_he 已提交
416
Formats a phone number based on specified formatting options. This API uses a promise to return the result.
S
shawn_he 已提交
417

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

S
shawn_he 已提交
420
**Parameters**
S
shawn_he 已提交
421

S
shawn_he 已提交
422
| Name     | Type               | Mandatory| Description                                                        |
S
shawn_he 已提交
423
| ----------- | ------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
424
| phoneNumber | string              | Yes  | Phone number.                                                  |
S
shawn_he 已提交
425
| options     | NumberFormatOptions | Yes  | Number formatting options defined in [NumberFormatOptions](#numberformatoptions7).|
S
shawn_he 已提交
426

S
shawn_he 已提交
427
**Return Value**
S
shawn_he 已提交
428

S
shawn_he 已提交
429
| Type                 | Description                                       |
S
shawn_he 已提交
430 431
| --------------------- | ------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.|
S
shawn_he 已提交
432

S
shawn_he 已提交
433
**Example**
S
shawn_he 已提交
434

S
shawn_he 已提交
435 436 437 438 439 440 441 442 443 444
```
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 已提交
445

S
shawn_he 已提交
446
## call.formatPhoneNumberToE164<sup>7+</sup>
S
shawn_he 已提交
447 448 449

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

S
shawn_he 已提交
450
Converts a phone number into the E.164 format. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
451 452 453 454 455

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 已提交
456 457
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
458
**Parameters**
S
shawn_he 已提交
459

S
shawn_he 已提交
460
| Name     | Type                       | Mandatory| Description                                                 |
S
shawn_he 已提交
461
| ----------- | --------------------------- | ---- | ----------------------------------------------------- |
S
shawn_he 已提交
462 463 464
| 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 已提交
465

S
shawn_he 已提交
466
**Example**
S
shawn_he 已提交
467

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


S
shawn_he 已提交
477
## call.formatPhoneNumberToE164<sup>7+</sup>
S
shawn_he 已提交
478 479 480

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

S
shawn_he 已提交
481
Converts a phone number into the E.164 format. This API uses a promise to return the result.
S
shawn_he 已提交
482 483 484 485 486

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 已提交
487 488
**System capability**: SystemCapability.Telephony.CallManager

S
shawn_he 已提交
489
**Parameters**
S
shawn_he 已提交
490

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

S
shawn_he 已提交
496
**Return Value**
S
shawn_he 已提交
497

S
shawn_he 已提交
498
| Type                 | Description                                                        |
S
shawn_he 已提交
499 500
| --------------------- | ------------------------------------------------------------ |
| Promise&lt;string&gt; | Promise used to return the result.|
S
shawn_he 已提交
501

S
shawn_he 已提交
502
**Example**
S
shawn_he 已提交
503

S
shawn_he 已提交
504 505 506 507 508 509 510 511 512 513
```
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 已提交
514

S
shawn_he 已提交
515
## DialOptions
S
shawn_he 已提交
516 517

Provides an option for determining whether a call is a video call.
S
shawn_he 已提交
518 519 520

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

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

S
shawn_he 已提交
525
## CallState
S
shawn_he 已提交
526 527

Enumerates call states.
S
shawn_he 已提交
528

S
shawn_he 已提交
529 530 531
**System capability**: SystemCapability.Telephony.CallManager

| Name              | Value  | Description                                                        |
S
shawn_he 已提交
532
| ------------------ | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
533 534 535 536
| CALL_STATE_UNKNOWN | -1   | The call status fails to be obtained and is unknown.                        |
| CALL_STATE_IDLE    | 0    | No call is in progress.                                    |
| CALL_STATE_RINGING | 1    | The call is in the ringing or waiting state.                                    |
| CALL_STATE_OFFHOOK | 2    | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.|
S
shawn_he 已提交
537

S
shawn_he 已提交
538
## EmergencyNumberOptions<sup>7+</sup>
S
shawn_he 已提交
539 540

Provides an option for determining whether a number is an emergency number for the SIM card in the specified slot.
S
shawn_he 已提交
541 542 543

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

S
shawn_he 已提交
544
| Name| Type  | Mandatory| Description                                      |
S
shawn_he 已提交
545
| ------ | ------ | ---- | ------------------------------------------ |
S
shawn_he 已提交
546
| slotId | number | No  | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
547

S
shawn_he 已提交
548
## NumberFormatOptions<sup>7+</sup>
S
shawn_he 已提交
549 550

Provides an option for number formatting.
S
shawn_he 已提交
551 552 553

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

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