• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.telephony.call (Call)
2
3The **call** module provides call management functions, including making calls, redirecting to the dial screen, obtaining the call status, and formatting phone numbers.
4
5To subscribe to call status changes, use [`observer.on('callStateChange')`](js-apis-observer.md#observeroncallstatechange).
6
7>**NOTE**
8>
9>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.
10
11## Modules to Import
12
13```ts
14import { call } from '@kit.TelephonyKit';
15```
16
17
18## call.dial<sup>(deprecated)</sup>
19
20dial\(phoneNumber: string, callback: AsyncCallback\<boolean\>\): void
21
22Initiates a call. This API uses an asynchronous callback to return the result.
23
24> **NOTE**
25>
26> This API is supported since API version 6 and deprecated since API version 9. The substitute API is available only for system applications.
27
28**Required permissions**: ohos.permission.PLACE_CALL (available only for system applications)
29
30**System capability**: SystemCapability.Telephony.CallManager
31
32**Parameters**
33
34| Name     | Type                        | Mandatory| Description                                   |
35| ----------- | ---------------------------- | ---- | --------------------------------------- |
36| phoneNumber | string                       | Yes  | Phone number.                             |
37| callback    | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.|
38
39**Example**
40
41```ts
42import { BusinessError } from '@kit.BasicServicesKit';
43
44call.dial("138xxxxxxxx", (err: BusinessError, data: boolean) => {
45    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
46});
47```
48
49
50## call.dial<sup>(deprecated)</sup>
51
52dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback\<boolean\>\): void
53
54Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
55
56> **NOTE**
57>
58> This API is supported since API version 6 and deprecated since API version 9. The substitute API is available only for system applications.
59
60**Required permissions**: ohos.permission.PLACE_CALL (available only for system applications)
61
62**System capability**: SystemCapability.Telephony.CallManager
63
64**Parameters**
65
66| Name     | Type                        | Mandatory| Description                                   |
67| ----------- | ---------------------------- | ---- | --------------------------------------- |
68| phoneNumber | string                       | Yes  | Phone number.                             |
69| options     | [DialOptions](#dialoptions)  | Yes  | Call option, which indicates whether the call is a voice call or video call. |
70| callback    | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.|
71
72**Example**
73
74```ts
75import { BusinessError } from '@kit.BasicServicesKit';
76
77let dialOptions: call.DialOptions = {
78    extras: false
79}
80call.dial("138xxxxxxxx", dialOptions, (err: BusinessError, data: boolean) => {
81    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
82});
83```
84
85## call.dial<sup>(deprecated)</sup>
86
87dial\(phoneNumber: string, options?: DialOptions\): Promise\<boolean\>
88
89Initiates a call. You can set call options as needed. This API uses a promise to return the result.
90
91> **NOTE**
92>
93> This API is supported since API version 6 and deprecated since API version 9. The substitute API is available only for system applications.
94
95**Required permissions**: ohos.permission.PLACE_CALL (available only for system applications)
96
97**System capability**: SystemCapability.Telephony.CallManager
98
99**Parameters**
100
101| Name     | Type                       | Mandatory| Description                                  |
102| ----------- | --------------------------- | ---- | -------------------------------------- |
103| phoneNumber | string                      | Yes  | Phone number.                            |
104| options     | [DialOptions](#dialoptions) | No  | Call option, which indicates whether the call is a voice call or video call.|
105
106**Return value**
107
108| Type                  | Description                                                        |
109| ---------------------- | ------------------------------------------------------------ |
110| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.|
111
112**Example**
113
114```ts
115import { BusinessError } from '@kit.BasicServicesKit';
116
117let dialOptions: call.DialOptions = {
118    extras: false
119}
120call.dial("138xxxxxxxx", dialOptions).then((data: boolean) => {
121    console.log(`dial success, promise: data->${JSON.stringify(data)}`);
122}).catch((err: BusinessError) => {
123    console.error(`dial fail, promise: err->${JSON.stringify(err)}`);
124});
125```
126
127## call.makeCall<sup>7+</sup>
128
129makeCall\(phoneNumber: string, callback: AsyncCallback\<void\>\): void
130
131Launches the call screen and displays the dialed number. This API uses an asynchronous callback to return the result. This API can be called only in a UIAbility.
132
133**Atomic service API**: This API can be used in atomic services since API version 11.
134
135**System capability**: SystemCapability.Applications.Contacts
136
137**Parameters**
138
139| Name     | Type                     | Mandatory| Description                                      |
140| ----------- | ------------------------- | ---- | ------------------------------------------ |
141| phoneNumber | string                    | Yes  | Phone number.                                |
142| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
143
144**Error codes**
145
146For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
147
148| ID| Error Message                                    |
149| -------- | -------------------------------------------- |
150| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
151| 8300001  | Invalid parameter value.                     |
152| 8300002  | Operation failed. Cannot connect to service. |
153| 8300003  | System internal error.                       |
154| 8300999  | Unknown error code.                          |
155
156**Example**
157
158```ts
159import { BusinessError } from '@kit.BasicServicesKit';
160// The tel URI format is supported since API version 15, for example, tel:13xxxx.
161call.makeCall("138xxxxxxxx", (err: BusinessError) => {
162    if (err) {
163        console.error(`makeCall fail, err->${JSON.stringify(err)}`);
164    } else {
165        console.log(`makeCall success`);
166    }
167});
168```
169
170
171## call.makeCall<sup>7+</sup>
172
173makeCall\(phoneNumber: string\): Promise\<void\>
174
175Launches the call screen and displays the dialed number. This API uses a promise to return the result. This API can be called only in a UIAbility.
176
177**Atomic service API**: This API can be used in atomic services since API version 11.
178
179**System capability**: SystemCapability.Applications.Contacts
180
181**Parameters**
182
183| Name     | Type  | Mandatory| Description      |
184| ----------- | ------ | ---- | ---------- |
185| phoneNumber | string | Yes  | Phone number.|
186
187**Return value**
188
189| Type               | Description                             |
190| ------------------- | --------------------------------- |
191| Promise&lt;void&gt; | Promise used to return the result.|
192
193**Error codes**
194
195For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
196
197| ID| Error Message                                    |
198| -------- | -------------------------------------------- |
199| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
200| 8300001  | Invalid parameter value.                     |
201| 8300002  | Operation failed. Cannot connect to service. |
202| 8300003  | System internal error.                       |
203| 8300999  | Unknown error code.                          |
204
205**Example**
206
207```ts
208import { BusinessError } from '@kit.BasicServicesKit';
209// The tel URI format is supported since API version 15, for example, tel:13xxxx.
210call.makeCall("138xxxxxxxx").then(() => {
211    console.log(`makeCall success`);
212}).catch((err: BusinessError) => {
213    console.error(`makeCall fail, promise: err->${JSON.stringify(err)}`);
214});
215```
216
217## call.makeCall<sup>12+</sup>
218
219makeCall\(context: Context, phoneNumber: string\): Promise\<void\>
220
221Launches the call screen and displays the dialed number. This API uses a promise to return the result. You need to declare the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission if you want to call the API in the background.
222
223**Atomic service API**: This API can be used in atomic services since API version 12.
224
225**System capability**: SystemCapability.Applications.Contacts
226
227**Parameters**
228
229| Name     | Type  | Mandatory| Description      |
230| ----------- | ------ | ---- | ---------- |
231| context | Context | Yes  | Application context.|
232| phoneNumber | string | Yes  | Phone number.|
233
234**Return value**
235
236| Type               | Description                             |
237| ------------------- | --------------------------------- |
238| Promise&lt;void&gt; | Promise used to return the result.|
239
240**Error codes**
241
242For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
243
244| ID| Error Message                                    |
245| -------- | -------------------------------------------- |
246| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
247| 8300002  | Operation failed. Cannot connect to service. |
248| 8300003  | System internal error.                       |
249
250**Example**
251
252>**NOTE**
253>
254>In the sample code provided in this topic, **this.context** is used to obtain **UIAbilityContext**, where **this** indicates a UIAbility instance inherited from **UIAbility**. To use UIAbilityContext APIs on pages, see [Obtaining the Context of UIAbility](../../application-models/uiability-usage.md#obtaining-the-context-of-uiability).
255
256<!--code_no_check-->
257```ts
258import { BusinessError } from '@kit.BasicServicesKit';
259// Obtain the application context.
260let context = this.getUIContext().getHostContext() as Context;
261// The tel URI format is supported since API version 15, for example, tel:13xxxx.
262call.makeCall(context, "138xxxxxxxx").then(() => {
263    console.log(`makeCall success`);
264}).catch((err: BusinessError) => {
265    console.error(`makeCall fail, promise: err->${JSON.stringify(err)}`);
266});
267```
268
269## call.hasCall
270
271hasCall\(callback: AsyncCallback\<boolean\>\): void
272
273Checks whether a call is in progress. This API uses an asynchronous callback to return the result.
274
275**System capability**: SystemCapability.Telephony.CallManager
276
277**Parameters**
278
279| Name  | Type                        | Mandatory| Description                                                        |
280| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
281| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. The value **true** indicates that a call is in progress, and the value **false** indicates the opposite.|
282
283**Example**
284
285```ts
286import { BusinessError } from '@kit.BasicServicesKit';
287
288call.hasCall((err: BusinessError, data: boolean) => {
289    if (err) {
290        console.error(`hasCall fail, err->${JSON.stringify(err)}`);
291    } else {
292        console.log(`hasCall success, data->${JSON.stringify(data)}`);
293    }
294});
295```
296
297
298## call.hasCall
299
300hasCall\(\): Promise\<boolean\>
301
302Checks whether a call is in progress. This API uses a promise to return the result.
303
304**System capability**: SystemCapability.Telephony.CallManager
305
306**Return value**
307
308| Type                  | Description                                   |
309| ---------------------- | --------------------------------------- |
310| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** indicates that a call is in progress, and the value **false** indicates the opposite.|
311
312**Example**
313
314```ts
315import { BusinessError } from '@kit.BasicServicesKit';
316
317call.hasCall().then(() => {
318    console.log(`hasCall success`);
319}).catch((err: BusinessError) => {
320    console.error(`hasCall fail, promise: err->${JSON.stringify(err)}`);
321});
322```
323
324## call.hasCallSync<sup>10+</sup>
325
326hasCallSync\(\): boolean
327
328Checks whether a call is in progress.
329
330**System capability**: SystemCapability.Telephony.CallManager
331
332**Return value**
333
334| Type                  | Description         |
335| ---------------------- |-------------|
336| boolean | Promise used to return the result. The value **true** indicates that a call is in progress, and the value **false** indicates the opposite.|
337
338**Example**
339
340```ts
341let hasCall: boolean = call.hasCallSync();
342console.log(`hasCallSync success, has call is ` + hasCall);
343```
344
345
346## call.getCallState
347
348getCallState\(callback: AsyncCallback\<CallState\>\): void
349
350Obtains the call status. This API uses an asynchronous callback to return the result.
351
352**System capability**: SystemCapability.Telephony.CallManager
353
354**Parameters**
355
356| Name  | Type                                        | Mandatory| Description                                |
357| -------- | -------------------------------------------- | ---- | ------------------------------------ |
358| callback | AsyncCallback&lt;[CallState](#callstate)&gt; | Yes  | Callback used to return the result.|
359
360**Example**
361
362```ts
363import { BusinessError } from '@kit.BasicServicesKit';
364
365call.getCallState((err: BusinessError, data: call.CallState) => {
366    if (err) {
367        console.error(`getCallState fail, err->${JSON.stringify(err)}`);
368    } else {
369        console.log(`getCallState success, data->${JSON.stringify(data)}`);
370    }
371});
372```
373
374
375## call.getCallState
376
377getCallState\(\): Promise\<CallState\>
378
379Obtains the call status. This API uses a promise to return the result.
380
381**System capability**: SystemCapability.Telephony.CallManager
382
383**Return value**
384
385| Type                                  | Description                                   |
386| -------------------------------------- | --------------------------------------- |
387| Promise&lt;[CallState](#callstate)&gt; | Promise used to return the result.|
388
389**Example**
390
391```ts
392import { BusinessError } from '@kit.BasicServicesKit';
393
394call.getCallState().then((data: call.CallState) => {
395    console.log(`getCallState success, promise: data->${JSON.stringify(data)}`);
396}).catch((err: BusinessError) => {
397    console.error(`getCallState fail, promise: err->${JSON.stringify(err)}`);
398});
399```
400
401## call.getCallStateSync<sup>10+</sup>
402
403getCallStateSync\(\): CallState
404
405Obtains the call status.
406
407**System capability**: SystemCapability.Telephony.CallManager
408
409**Return value**
410
411| Type                                 | Description         |
412| ------------------------------------- |-------------|
413| [CallState](#callstate) | Promise used to return the result.|
414
415**Example**
416
417```ts
418let callState: call.CallState = call.getCallStateSync();
419console.log(`the call state is:` + callState);
420```
421
422## call.hasVoiceCapability<sup>7+</sup>
423
424hasVoiceCapability\(\): boolean
425
426Checks whether a device supports voice calls.
427
428**System capability**: SystemCapability.Telephony.CallManager
429
430**Return value**
431
432| Type   | Description                                                        |
433| ------- | ------------------------------------------------------------ |
434| boolean | Result indicating whether the device supports voice calls. The value **true** indicates yes, and the value **false** indicates no.|
435
436```ts
437let result: boolean = call.hasVoiceCapability();
438console.log(`hasVoiceCapability: ${JSON.stringify(result)}`);
439```
440
441## call.isEmergencyPhoneNumber<sup>7+</sup>
442
443isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback\<boolean\>\): void
444
445Checks whether the called number is an emergency number. This API uses an asynchronous callback to return the result.
446
447**System capability**: SystemCapability.Telephony.CallManager
448
449**Parameters**
450
451| Name     | Type                        | Mandatory| Description                                                        |
452| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ |
453| phoneNumber | string                       | Yes  | Phone number.                                                  |
454| callback    | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. The value **true** indicates that the called number is an emergency number, and the value **false** indicates the opposite.|
455
456**Error codes**
457
458For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
459
460| ID| Error Message                                    |
461| -------- | -------------------------------------------- |
462| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
463| 8300001  | Invalid parameter value.                     |
464| 8300002  | Operation failed. Cannot connect to service. |
465| 8300003  | System internal error.                       |
466| 8300999  | Unknown error code.                          |
467
468**Example**
469
470```ts
471import { BusinessError } from '@kit.BasicServicesKit';
472
473call.isEmergencyPhoneNumber("138xxxxxxxx", (err: BusinessError, data: boolean) => {
474    if (err) {
475        console.error(`isEmergencyPhoneNumber fail, err->${JSON.stringify(err)}`);
476    } else {
477        console.log(`isEmergencyPhoneNumber success, data->${JSON.stringify(data)}`);
478    }
479});
480```
481
482
483## call.isEmergencyPhoneNumber<sup>7+</sup>
484
485isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback\<boolean\>\): void
486
487Checks whether the called number is an emergency number based on the phone number. This API uses an asynchronous callback to return the result.
488
489**System capability**: SystemCapability.Telephony.CallManager
490
491**Parameters**
492
493| Name     | Type                                              | Mandatory| Description                                                        |
494| ----------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
495| phoneNumber | string                                             | Yes  | Phone number.                                                  |
496| options     | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes  | Emergency number options.                                              |
497| callback    | AsyncCallback&lt;boolean&gt;                       | Yes  | Callback used to return the result. The value **true** indicates that the called number is an emergency number, and the value **false** indicates the opposite.|
498
499**Error codes**
500
501For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
502
503| ID| Error Message                                    |
504| -------- | -------------------------------------------- |
505| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
506| 8300001  | Invalid parameter value.                     |
507| 8300002  | Operation failed. Cannot connect to service. |
508| 8300003  | System internal error.                       |
509| 8300999  | Unknown error code.                          |
510
511**Example**
512
513```ts
514import { BusinessError } from '@kit.BasicServicesKit';
515
516let options: call.EmergencyNumberOptions = {slotId: 1}
517call.isEmergencyPhoneNumber("112", options, (err: BusinessError, data: boolean) => {
518    if (err) {
519        console.error(`isEmergencyPhoneNumber fail, err->${JSON.stringify(err)}`);
520    } else {
521        console.log(`isEmergencyPhoneNumber success, data->${JSON.stringify(data)}`);
522    }
523});
524```
525
526
527## call.isEmergencyPhoneNumber<sup>7+</sup>
528
529isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Promise\<boolean\>
530
531Checks whether the called number is an emergency number based on the phone number. This API uses a promise to return the result.
532
533**System capability**: SystemCapability.Telephony.CallManager
534
535**Parameters**
536
537| Name     | Type                                              | Mandatory| Description          |
538| ----------- | -------------------------------------------------- | ---- | -------------- |
539| phoneNumber | string                                             | Yes  | Phone number.    |
540| options     | [EmergencyNumberOptions](#emergencynumberoptions7) | No  | Emergency number options.|
541
542**Return value**
543
544| Type                  | Description                                               |
545| ---------------------- | --------------------------------------------------- |
546| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** indicates that the called number is an emergency number, and the value **false** indicates the opposite.|
547
548**Error codes**
549
550For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
551
552| ID| Error Message                                    |
553| -------- | -------------------------------------------- |
554| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
555| 8300001  | Invalid parameter value.                     |
556| 8300002  | Operation failed. Cannot connect to service. |
557| 8300003  | System internal error.                       |
558| 8300999  | Unknown error code.                          |
559
560**Example**
561
562```ts
563import { BusinessError } from '@kit.BasicServicesKit';
564
565let options: call.EmergencyNumberOptions = {slotId: 1}
566call.isEmergencyPhoneNumber("138xxxxxxxx", options).then((data: boolean) => {
567    console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`);
568}).catch((err: BusinessError) => {
569    console.error(`isEmergencyPhoneNumber fail, promise: err->${JSON.stringify(err)}`);
570});
571```
572
573## call.formatPhoneNumber<sup>7+</sup>
574
575formatPhoneNumber\(phoneNumber: string, callback: AsyncCallback\<string\>\): void
576
577Formats a phone number. This API uses an asynchronous callback to return the result.
578
579A formatted phone number is a standard numeric string, for example, 555 0100.
580
581**System capability**: SystemCapability.Telephony.CallManager
582
583**Parameters**
584
585| Name     | Type                       | Mandatory| Description                                |
586| ----------- | --------------------------- | ---- | ------------------------------------ |
587| phoneNumber | string                      | Yes  | Phone number.                          |
588| callback    | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.|
589
590**Error codes**
591
592For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
593
594| ID| Error Message                                    |
595| -------- | -------------------------------------------- |
596| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
597| 8300001  | Invalid parameter value.                     |
598| 8300002  | Operation failed. Cannot connect to service. |
599| 8300003  | System internal error.                       |
600| 8300999  | Unknown error code.                          |
601
602**Example**
603
604```ts
605import { BusinessError } from '@kit.BasicServicesKit';
606
607call.formatPhoneNumber("138xxxxxxxx", (err: BusinessError, data: string) => {
608    if (err) {
609        console.error(`formatPhoneNumber fail, err->${JSON.stringify(err)}`);
610    } else {
611        console.log(`formatPhoneNumber success, data->${JSON.stringify(data)}`);
612    }
613});
614```
615
616## call.formatPhoneNumber<sup>7+</sup>
617
618formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback\<string\>\): void
619
620Formats a phone number based on specified formatting options. This API uses an asynchronous callback to return the result.
621
622A formatted phone number is a standard numeric string, for example, 555 0100.
623
624**System capability**: SystemCapability.Telephony.CallManager
625
626**Parameters**
627
628| Name     | Type                                        | Mandatory| Description                                |
629| ----------- | -------------------------------------------- | ---- | ------------------------------------ |
630| phoneNumber | string                                       | Yes  | Phone number.                          |
631| options     | [NumberFormatOptions](#numberformatoptions7) | Yes  | Number formatting options, for example, country code.              |
632| callback    | AsyncCallback&lt;string&gt;                  | Yes  | Callback used to return the result.|
633
634**Error codes**
635
636For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
637
638| ID| Error Message                                    |
639| -------- | -------------------------------------------- |
640| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
641| 8300001  | Invalid parameter value.                     |
642| 8300002  | Operation failed. Cannot connect to service. |
643| 8300003  | System internal error.                       |
644| 8300999  | Unknown error code.                          |
645
646**Example**
647
648```ts
649import { BusinessError } from '@kit.BasicServicesKit';
650
651let options: call.NumberFormatOptions = {
652    countryCode: "CN"
653}
654call.formatPhoneNumber("138xxxxxxxx", options, (err: BusinessError, data: string) => {
655    if (err) {
656        console.error(`formatPhoneNumber fail, err->${JSON.stringify(err)}`);
657    } else {
658        console.log(`formatPhoneNumber success, data->${JSON.stringify(data)}`);
659    }
660});
661```
662
663
664## call.formatPhoneNumber<sup>7+</sup>
665
666formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise\<string\>
667
668Formats a phone number based on specified formatting options. This API uses a promise to return the result.
669
670A formatted phone number is a standard numeric string, for example, 555 0100.
671
672**System capability**: SystemCapability.Telephony.CallManager
673
674**Parameters**
675
676| Name     | Type                                        | Mandatory| Description                  |
677| ----------- | -------------------------------------------- | ---- | ---------------------- |
678| phoneNumber | string                                       | Yes  | Phone number.            |
679| options     | [NumberFormatOptions](#numberformatoptions7) | No  | Number formatting options, for example, country code.|
680
681**Return value**
682
683| Type                 | Description                                       |
684| --------------------- | ------------------------------------------- |
685| Promise&lt;string&gt; | Promise used to return the result.|
686
687**Error codes**
688
689For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
690
691| ID| Error Message                                    |
692| -------- | -------------------------------------------- |
693| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
694| 8300001  | Invalid parameter value.                     |
695| 8300002  | Operation failed. Cannot connect to service. |
696| 8300003  | System internal error.                       |
697| 8300999  | Unknown error code.                          |
698
699**Example**
700
701```ts
702import { BusinessError } from '@kit.BasicServicesKit';
703
704let options: call.NumberFormatOptions = {
705    countryCode: "CN"
706}
707call.formatPhoneNumber("138xxxxxxxx", options).then((data: string) => {
708    console.log(`formatPhoneNumber success, promise: data->${JSON.stringify(data)}`);
709}).catch((err: BusinessError) => {
710    console.error(`formatPhoneNumber fail, promise: err->${JSON.stringify(err)}`);
711});
712```
713
714## call.formatPhoneNumberToE164<sup>7+</sup>
715
716formatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: AsyncCallback\<string\>\): void
717
718Converts a phone number into the E.164 format. This API uses an asynchronous callback to return the result.
719
720The 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.
721
722**System capability**: SystemCapability.Telephony.CallManager
723
724**Parameters**
725
726| Name     | Type                       | Mandatory| Description                                                 |
727| ----------- | --------------------------- | ---- | ----------------------------------------------------- |
728| phoneNumber | string                      | Yes  | Phone number.                                           |
729| countryCode | string                      | Yes  | Country code, for example, **CN** (China). All country codes are supported.             |
730| callback    | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.|
731
732**Error codes**
733
734For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
735
736| ID| Error Message                                    |
737| -------- | -------------------------------------------- |
738| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
739| 8300001  | Invalid parameter value.                     |
740| 8300002  | Operation failed. Cannot connect to service. |
741| 8300003  | System internal error.                       |
742| 8300999  | Unknown error code.                          |
743
744**Example**
745
746```ts
747import { BusinessError } from '@kit.BasicServicesKit';
748
749call.formatPhoneNumberToE164("138xxxxxxxx", "CN", (err: BusinessError, data: string) => {
750    if (err) {
751        console.error(`formatPhoneNumberToE164 fail, err->${JSON.stringify(err)}`);
752    } else {
753        console.log(`formatPhoneNumberToE164 success, data->${JSON.stringify(data)}`);
754    }
755});
756```
757
758
759## call.formatPhoneNumberToE164<sup>7+</sup>
760
761formatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise\<string\>
762
763Converts a phone number into the E.164 format. This API uses a promise to return the result.
764
765The 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.
766
767All country codes are supported.
768
769**System capability**: SystemCapability.Telephony.CallManager
770
771**Parameters**
772
773| Name     | Type  | Mandatory| Description                                    |
774| ----------- | ------ | ---- | ---------------------------------------- |
775| phoneNumber | string | Yes  | Phone number.                              |
776| countryCode | string | Yes  | Country code, for example, **CN** (China). All country codes are supported.|
777
778**Return value**
779
780| Type                 | Description                                                        |
781| --------------------- | ------------------------------------------------------------ |
782| Promise&lt;string&gt; | Promise used to return the result.|
783
784**Error codes**
785
786For details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md).
787
788| ID| Error Message                                    |
789| -------- | -------------------------------------------- |
790| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;|
791| 8300001  | Invalid parameter value.                     |
792| 8300002  | Operation failed. Cannot connect to service. |
793| 8300003  | System internal error.                       |
794| 8300999  | Unknown error code.                          |
795
796**Example**
797
798```ts
799import { BusinessError } from '@kit.BasicServicesKit';
800
801call.formatPhoneNumberToE164("138xxxxxxxx", "CN").then((data: string) => {
802    console.log(`formatPhoneNumberToE164 success, promise: data->${JSON.stringify(data)}`);
803}).catch((err: BusinessError) => {
804    console.error(`formatPhoneNumberToE164 fail, promise: err->${JSON.stringify(err)}`);
805});
806```
807
808## DialOptions
809
810Provides an option for determining whether a call is a video call.
811
812**System capability**: SystemCapability.Telephony.CallManager
813
814|        Name             | Type                              | Mandatory| Description                                                                                            |
815| ------------------------ | ---------------------------------- | ---- | ----------------------------------------------------------------------------------------------- |
816| extras                   | boolean                            | No  | Whether the call is a video call. <br>- **true**: video call<br>- **false** (default): voice call  |
817
818## CallState
819
820Enumerates call states.
821
822**System capability**: SystemCapability.Telephony.CallManager
823
824| Name              | Value  | Description                                                        |
825| ------------------ | ---- | ------------------------------------------------------------ |
826| CALL_STATE_UNKNOWN | -1   | The call status fails to be obtained and is unknown.                        |
827| CALL_STATE_IDLE    | 0    | No call is in progress.                                    |
828| CALL_STATE_RINGING | 1    | The call is in the ringing or waiting state.                                    |
829| CALL_STATE_OFFHOOK | 2    | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.|
830| CALL_STATE_ANSWERED<sup>11+</sup> | 3    | The incoming call is answered.|
831
832## EmergencyNumberOptions<sup>7+</sup>
833
834Provides an option for determining whether a number is an emergency number for the SIM card in the specified slot.
835
836**System capability**: SystemCapability.Telephony.CallManager
837
838|  Name | Type  | Mandatory| Description                                          |
839| ------ | ------ | ---- | ---------------------------------------------- |
840| slotId | number | No  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
841
842## NumberFormatOptions<sup>7+</sup>
843
844Provides an option for number formatting.
845
846**System capability**: SystemCapability.Telephony.CallManager
847
848|    Name    | Type  | Mandatory| Description                                                      |
849| ----------- | ------ | ---- | ---------------------------------------------------------- |
850| countryCode | string | No  | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.|
851