“097c99b661999ada844e0732659bf0a41e57129a”上不存在“tests/examples/go/git@gitcode.net:qq_37101384/tdengine.git”
提交 115e5254 编写于 作者: S shawn_he

update docs

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 15c66a99
...@@ -23,10 +23,10 @@ Initiates a call. This function uses an asynchronous callback to return the exec ...@@ -23,10 +23,10 @@ Initiates a call. This function uses an asynchronous callback to return the exec
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | ------------------------------------------------- | | ----------- | ---------------------------- | ---- | ------------------------------------------------- |
| phoneNumber | string | Yes| Phone number.| | phoneNumber | string | Yes | Phone number. |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result.<br/> - **true**: success <br/> - **false**: failure| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure|
**Example** **Example**
...@@ -49,11 +49,11 @@ Initiates a call. You can set call options as needed. This function uses an asyn ...@@ -49,11 +49,11 @@ Initiates a call. You can set call options as needed. This function uses an asyn
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | ------------------------------------------------- | | ----------- | ---------------------------- | ---- | ------------------------------------------------- |
| phoneNumber | string | Yes| Phone number.| | phoneNumber | string | Yes | Phone number. |
| options | DialOptions | Yes| Call options. For details, see [DialOptions](#DialOptions).| | 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| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure|
**Example** **Example**
...@@ -78,14 +78,14 @@ Initiates a call. You can set call options as needed. This function uses a promi ...@@ -78,14 +78,14 @@ Initiates a call. You can set call options as needed. This function uses a promi
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | ----------- | ---- | ------------------------------------------- | | ----------- | ----------- | ---- | ------------------------------------------- |
| phoneNumber | string | Yes| Phone number.| | phoneNumber | string | Yes | Phone number. |
| options | DialOptions | Yes| Call options. For details, see [DialOptions](#DialOptions).| | options | DialOptions | Yes | Call options. For details, see [DialOptions](#DialOptions).|
**Return value** **Return Value**
| Type| Description| | Type | Description |
| ---------------------- | --------------------------------- | | ---------------------- | --------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.|
...@@ -102,6 +102,61 @@ promise.then(data => { ...@@ -102,6 +102,61 @@ promise.then(data => {
}); });
``` ```
## 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)}`);
});
```
## call.hasCall<a name=call.hasCall-callback></a> ## call.hasCall<a name=call.hasCall-callback></a>
hasCall\(callback: AsyncCallback<boolean\>\): void hasCall\(callback: AsyncCallback<boolean\>\): void
...@@ -112,9 +167,9 @@ Checks whether a call is in progress. This function uses an asynchronous callbac ...@@ -112,9 +167,9 @@ Checks whether a call is in progress. This function uses an asynchronous callbac
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| 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. | | 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.|
**Example** **Example**
...@@ -133,9 +188,9 @@ Checks whether a call is in progress. This function uses a promise to return the ...@@ -133,9 +188,9 @@ Checks whether a call is in progress. This function uses a promise to return the
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
**Return value** **Return Value**
| Type| Description| | Type | Description |
| ---------------------- | --------------------------------------- | | ---------------------- | --------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.|
...@@ -161,9 +216,9 @@ Obtains the call status. This function uses an asynchronous callback to return t ...@@ -161,9 +216,9 @@ Obtains the call status. This function uses an asynchronous callback to return t
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | ------------------------------------ | | -------- | -------------------------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback&lt;[CallState](#CallState)&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;[CallState](#CallState)&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -182,9 +237,9 @@ Obtains the call status. This function uses a promise to return the result. ...@@ -182,9 +237,9 @@ Obtains the call status. This function uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
**Return value** **Return Value**
| Type| Description| | Type | Description |
| -------------------------------------- | ----------------------------------------- | | -------------------------------------- | ----------------------------------------- |
| Promise&lt;[CallState](#CallState)&gt; | Promise used to return the result.| | Promise&lt;[CallState](#CallState)&gt; | Promise used to return the result.|
...@@ -199,6 +254,25 @@ promise.then(data => { ...@@ -199,6 +254,25 @@ promise.then(data => {
}); });
``` ```
## 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)}`);
```
## call.isEmergencyPhoneNumber<sup>7+</sup><a name=call.isEmergencyPhoneNumber-callback1></a> ## call.isEmergencyPhoneNumber<sup>7+</sup><a name=call.isEmergencyPhoneNumber-callback1></a>
isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void
...@@ -209,10 +283,10 @@ Checks whether the call number of the SIM card in the specified slot is an emerg ...@@ -209,10 +283,10 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | | ----------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| phoneNumber | string | Yes| Phone number.| | 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.| | 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.|
**Example** **Example**
...@@ -233,11 +307,11 @@ Checks whether the call number of the SIM card in the specified slot is an emerg ...@@ -233,11 +307,11 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | | ----------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| phoneNumber | string | Yes| Phone number.| | phoneNumber | string | Yes | Phone number. |
| options | EmergencyNumberOptions | Yes| Emergency number options defined in [EmergencyNumberOptions](#EmergencyNumberOptions).| | 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.| | 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.|
**Example** **Example**
...@@ -258,14 +332,14 @@ Checks whether the call number of the SIM card in the specified slot is an emerg ...@@ -258,14 +332,14 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | ---------------------- | ---- | ------------------------------------------------------------ | | ----------- | ---------------------- | ---- | ------------------------------------------------------------ |
| phoneNumber | string | Yes| Phone number.| | phoneNumber | string | Yes | Phone number. |
| options | EmergencyNumberOptions | Yes| Emergency number options defined in [EmergencyNumberOptions](#EmergencyNumberOptions).| | options | EmergencyNumberOptions | Yes | Emergency number options defined in [EmergencyNumberOptions](#EmergencyNumberOptions).|
**Return value** **Return Value**
| Type| Description| | Type | Description |
| ---------------------- | --------------------------------------------------- | | ---------------------- | --------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.|
...@@ -290,10 +364,10 @@ Formats a phone number based on the specified ISO country code. This function us ...@@ -290,10 +364,10 @@ Formats a phone number based on the specified ISO country code. This function us
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ------------------------------------ | | ----------- | --------------------------- | ---- | ------------------------------------ |
| phoneNumber | string | Yes| Phone number.| | phoneNumber | string | Yes | Phone number. |
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -314,11 +388,11 @@ Formats a phone number based on specified formatting options. This function uses ...@@ -314,11 +388,11 @@ Formats a phone number based on specified formatting options. This function uses
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | | ----------- | --------------------------- | ---- | ------------------------------------------------------------ |
| phoneNumber | string | Yes| Phone number.| | phoneNumber | string | Yes | Phone number. |
| options | NumberFormatOptions | Yes| Number formatting options defined in [NumberFormatOptions](#NumberFormatOptions).| | options | NumberFormatOptions | Yes | Number formatting options defined in [NumberFormatOptions](#NumberFormatOptions).|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -341,14 +415,14 @@ Formats a phone number based on specified formatting options. This function uses ...@@ -341,14 +415,14 @@ Formats a phone number based on specified formatting options. This function uses
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | ------------------- | ---- | ------------------------------------------------------------ | | ----------- | ------------------- | ---- | ------------------------------------------------------------ |
| phoneNumber | string | Yes| Phone number.| | phoneNumber | string | Yes | Phone number. |
| options | NumberFormatOptions | Yes| Number formatting options defined in [NumberFormatOptions](#NumberFormatOptions).| | options | NumberFormatOptions | Yes | Number formatting options defined in [NumberFormatOptions](#NumberFormatOptions).|
**Return value** **Return Value**
| Type| Description| | Type | Description |
| --------------------- | ------------------------------------------- | | --------------------- | ------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -379,11 +453,11 @@ All country codes are supported. ...@@ -379,11 +453,11 @@ All country codes are supported.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ----------------------------------------------------- | | ----------- | --------------------------- | ---- | ----------------------------------------------------- |
| phoneNumber | string | Yes| Phone number.| | phoneNumber | string | Yes | Phone number. |
| countryCode | string | Yes| Country code, for example, **CN** (China). All country codes are supported.| | 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.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -410,14 +484,14 @@ All country codes are supported. ...@@ -410,14 +484,14 @@ All country codes are supported.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------------------------------------- | | ----------- | ------ | ---- | ---------------------------------------- |
| phoneNumber | string | Yes| Phone number.| | phoneNumber | string | Yes | Phone number. |
| countryCode | string | Yes| Country code, for example, **CN** (China). All country codes are supported.| | countryCode | string | Yes | Country code, for example, **CN** (China). All country codes are supported.|
**Return value** **Return Value**
| Type| Description| | Type | Description |
| --------------------- | ------------------------------------------------------------ | | --------------------- | ------------------------------------------------------------ |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -440,20 +514,20 @@ Provides an option for determining whether a call is a video call. ...@@ -440,20 +514,20 @@ Provides an option for determining whether a call is a video call.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
| Name| Type| Mandatory| Description| | Parameter | Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------------------------------------------------ | | ------ | ------- | ---- | ------------------------------------------------------------ |
| extras | boolean | No| Indication of a video call. The options are as follows: <br/> - **true**: video call <br/> - **false**: voice call| | extras | boolean | No | Indication of a video call. <br>- **true**: video call<br>- **false** (default): voice call|
## CallState<a name=CallState></a> ## CallState<a name=CallState></a>
Enumerates call states. Enumerates call states.
| Variable| Value| Description| | Variable | Value | Description |
| ------------------ | ---- | ------------------------------------------------------------ | | ------------------ | ---- | ------------------------------------------------------------ |
| CALL_STATE_UNKNOWN | -1 | The call status fails to be obtained and is unknown. <br />**System capability**: SystemCapability.Telephony.CallManager| | 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_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_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| | 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|
## EmergencyNumberOptions<sup>7+</sup><a name=EmergencyNumberOptions></a> ## EmergencyNumberOptions<sup>7+</sup><a name=EmergencyNumberOptions></a>
...@@ -461,9 +535,9 @@ Provides an option for determining whether a number is an emergency number for t ...@@ -461,9 +535,9 @@ Provides an option for determining whether a number is an emergency number for t
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
| Name| Type| Mandatory| Description| | Parameter | Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------ |
| slotId | number | No| SIM card slot ID.<br/> - **0**: slot 1 <br/> - **1**: slot 2| | slotId | number | No | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
## NumberFormatOptions<sup>7+</sup><a name=NumberFormatOptions></a> ## NumberFormatOptions<sup>7+</sup><a name=NumberFormatOptions></a>
...@@ -471,6 +545,6 @@ Provides an option for number formatting. ...@@ -471,6 +545,6 @@ Provides an option for number formatting.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
| Name| Type| Mandatory| Description| | Parameter | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------------------------------------------------------- | | ----------- | ------ | ---- | ---------------------------------------------------------- |
| countryCode | string | No| Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.| | countryCode | string | No | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.|
...@@ -20,11 +20,11 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp ...@@ -20,11 +20,11 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ------------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ | | ------------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
| pdu | Array&lt;number&gt; | Yes| PDU, which is obtained from the received SMS message.| | pdu | Array&lt;number&gt; | Yes | PDU, which is obtained from the received SMS message. |
| specification | string | Yes| SMS protocol type. The options are as follows: <br/> - **3gpp**: GSM/UMTS/LTE SMS<br/> - **3gpp2**: CDMA SMS| | specification | string | Yes | SMS protocol type. <br>- **3gpp**: GSM/UMTS/LTE SMS<br>- **3gpp2**: CDMA SMS|
| callback | AsyncCallback&lt;[ShortMessage](#ShortMessage)&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;[ShortMessage](#ShortMessage)&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -48,14 +48,14 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol. ...@@ -48,14 +48,14 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ------------- | ------------------- | ---- | ------------------------------------------------------------ | | ------------- | ------------------- | ---- | ------------------------------------------------------------ |
| pdu | Array&lt;number&gt; | Yes| PDU, which is obtained from the received SMS message.| | pdu | Array&lt;number&gt; | Yes | PDU, which is obtained from the received SMS message. |
| specification | string | Yes| SMS protocol type. The options are as follows: <br/> - **3gpp**: GSM/UMTS/LTE SMS<br/> - **3gpp2**: CDMA SMS| | specification | string | Yes | SMS protocol type. <br>- **3gpp**: GSM/UMTS/LTE SMS<br>- **3gpp2**: CDMA SMS|
**Return value** **Return Value**
| Type| Description| | Type | Description |
| -------------------------------------------- | --------------------------------- | | -------------------------------------------- | --------------------------------- |
| Promise&lt;[ShortMessage](#ShortMessage)&gt; | Promise used to return the result.| | Promise&lt;[ShortMessage](#ShortMessage)&gt; | Promise used to return the result.|
...@@ -85,9 +85,9 @@ Sends an SMS message. ...@@ -85,9 +85,9 @@ Sends an SMS message.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [SendMessageOptions](#SendMessageOptions) | Yes| Options (including the callback) for sending an SMS message. For details, see [SendMessageOptions](#SendMessageOptions).| | options | [SendMessageOptions](#SendMessageOptions) | Yes | Options (including the callback) for sending an SMS message. For details, see [SendMessageOptions](#SendMessageOptions).|
**Example** **Example**
...@@ -118,9 +118,9 @@ Obtains the default slot of the SIM card used to send SMS messages. This functio ...@@ -118,9 +118,9 @@ Obtains the default slot of the SIM card used to send SMS messages. This functio
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------------------- | | -------- | --------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result. <br/> - **0**: slot 1 <br/> - **1**: slot 2| | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Example** **Example**
...@@ -139,16 +139,16 @@ Obtains the default slot of the SIM card used to send SMS messages. This functio ...@@ -139,16 +139,16 @@ Obtains the default slot of the SIM card used to send SMS messages. This functio
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
**Return value** **Return Value**
| Type| Description| | Type | Description |
| --------------- | ------------------------------------------------------------ | | --------------- | ------------------------------------------------------------ |
| Promise<number> | Promise used to return the result.<br/> - **0**: slot 1<br/> - **1**: slot 2| | Promise<number> | Promise used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Example** **Example**
``` ```
let promise = call.getDefaultSmsSlotId(); let promise = sms.getDefaultSmsSlotId();
promise.then(data => { promise.then(data => {
console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -169,11 +169,11 @@ Sets the short message service center (SMSC) address. This function uses an asyn ...@@ -169,11 +169,11 @@ Sets the short message service center (SMSC) address. This function uses an asyn
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------------------- | | -------- | ------------------------- | ---- | ----------------------------------------- |
| slotId | number | Yes| SIM card slot ID: <br/> - **0**: slot 1<br/> - **1**: slot 2| | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| smscAddr | string | Yes| SMSC address. | | smscAddr | string | Yes | SMSC address. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -198,14 +198,14 @@ Sets the SMSC address. This function uses a promise to return the result. ...@@ -198,14 +198,14 @@ Sets the SMSC address. This function uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ----------------------------------------- | | -------- | ------ | ---- | ----------------------------------------- |
| slotId | number | Yes| SIM card slot ID: <br/> - **0**: slot 1<br/> - **1**: slot 2| | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| smscAddr | string | Yes| SMSC address. | | smscAddr | string | Yes | SMSC address. |
**Return value** **Return Value**
| Type| Description| | Type | Description |
| ------------------- | ------------------------------- | | ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
...@@ -233,12 +233,14 @@ Obtains the SMSC address. This function uses an asynchronous callback to return ...@@ -233,12 +233,14 @@ Obtains the SMSC address. This function uses an asynchronous callback to return
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
**Note:** This is a system API and it is used only for system applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ----------------------------------------- | | -------- | --------------------------- | ---- | ----------------------------------------- |
| slotId | number | Yes| SIM card slot ID: <br/> - **0**: slot 1<br/> - **1**: slot 2| | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -260,15 +262,17 @@ Obtains the SMSC address. This function uses a promise to return the result. ...@@ -260,15 +262,17 @@ Obtains the SMSC address. This function uses a promise to return the result.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
**Note:** This is a system API and it is used only for system applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----------------------------------------- | | ------ | ------ | ---- | ----------------------------------------- |
| slotId | number | Yes| SIM card slot ID: <br/> - **0**: slot 1<br/> - **1**: slot 2| | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value** **Return Value**
| Type| Description| | Type | Description |
| --------------------- | --------------------------------------------- | | --------------------- | --------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -284,6 +288,24 @@ promise.then(data => { ...@@ -284,6 +288,24 @@ promise.then(data => {
}); });
``` ```
## sms.hasSmsCapability<sup>7+</sup><a name=sms.hasSmsCapability></a>
hasSmsCapability(): boolean
Checks whether the current device can send and receive SMS messages. This function works in synchronous mode.
**System capability**: SystemCapability.Telephony.SmsMms
**Return Value**
| Type | Description |
| ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.|
```
let result = sms.hasSmsCapability();
console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
```
## ShortMessage<a name=ShortMessage></a> ## ShortMessage<a name=ShortMessage></a>
...@@ -291,36 +313,32 @@ Defines an SMS message instance. ...@@ -291,36 +313,32 @@ Defines an SMS message instance.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Variable| Type| Description| | Variable | Type | Description |
| ------------------------ | --------------------------------------- | ------------------------------------------------------------ | | ------------------------ | --------------------------------------- | ------------------------------------------------------------ |
| emailAddress | string | Email address.| | hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: the path in which the mobile phone can reply to the SMS message through the originating SMSC.|
| emailMessageBody | string | Email body.| | isReplaceMessage | boolean | Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see section 9.2.3.9 in **3GPP TS 23.040**.|
| hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**. <br/>**TP-Reply-Path**: the path in which the mobile phone can reply to the SMS message through the originating SMSC.| | isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**.<br>**SMS-Status-Report**: a message sent from the SMSC to the mobile station to show the SMS message delivery status.|
| isEmailMessage | boolean | Whether the received SMS message is an email.| | messageClass | [ShortMessageClass](#ShortMessageClass) | SMS message type. |
| isReplaceMessage | boolean | Whether the received SMS message is a **replace short message**. The default value is **false**. <br/>For details, see section 9.2.3.9 in **3GPP TS 23.040**.| | pdu | Array&lt;number&gt; | PDU in the SMS message. |
| isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**. <br/>SMS delivery status report: a message sent from the SMSC to show the current status of the SMS message you delivered.| | protocolId | number | ID of the protocol used for sending SMS messages. |
| messageClass | [ShortMessageClass](#ShortMessageClass) | SMS message type.| | scAddress | string | Address of the short message service center (SMSC). |
| pdu | Array&lt;number&gt; | PDU in the SMS message.| | scTimestamp | number | SMSC timestamp. |
| protocolId | number | ID of the protocol used for sending SMS messages.|
| scAddress | string | Address of the short message service center (SMSC).|
| scTimestamp | number | SMSC timestamp.|
| status | number | SMS message status sent by the SMSC in the **SMS-STATUS-REPORT** message.| | status | number | SMS message status sent by the SMSC in the **SMS-STATUS-REPORT** message.|
| userRawData | Array&lt;number&gt; | User data except the data header.| | visibleMessageBody | string | SMS message body. |
| visibleMessageBody | string | SMS message body.| | visibleRawAddress | string | Sender address. |
| visibleRawAddress | string | Sender address.|
## ShortMessageClass<a name=ShortMessageClass></a> ## ShortMessageClass<a name=ShortMessageClass></a>
Enumerates SMS message types. Enumerates SMS message types.
| Variable| Value| Description| | Variable | Value | Description |
| ---------------- | ---- | ------------------------------------------------------------ | | ---------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown type. <br />**System capability**: SystemCapability.Telephony.SmsMms| | UNKNOWN | 0 | Unknown type.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received. <br />**System capability**: SystemCapability.Telephony.SmsMms| | INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card. <br />**System capability**: SystemCapability.Telephony.SmsMms| | OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card. <br />**System capability**: SystemCapability.Telephony.SmsMms| | SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| FORWARD_MESSAGE | 4 | Message to be forwarded to another device. <br />**System capability**: SystemCapability.Telephony.SmsMms| | FORWARD_MESSAGE | 4 | Message to be forwarded to another device.<br>**System capability**: SystemCapability.Telephony.SmsMms|
## SendMessageOptions<a name=SendMessageOptions></a> ## SendMessageOptions<a name=SendMessageOptions></a>
...@@ -331,15 +349,15 @@ For example, you can specify the SMS message type by the optional parameter **co ...@@ -331,15 +349,15 @@ For example, you can specify the SMS message type by the optional parameter **co
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Name| Type| Mandatory| Description| | Parameter | Type | Mandatory| Description |
| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes| Slot ID of the SIM card used for sending SMS messages: <br/> - **0**: slot 1 <br/> - **1**: slot 2| | slotId | number | Yes | Slot ID of the SIM card used for sending SMS messages. <br>- **0**: card slot 1<br>- **1**: card slot 2 |
| destinationHost | string | Yes| Destination address of the SMS message.| | destinationHost | string | Yes | Destination address of the SMS message. |
| content | string \| Array&lt;number&gt; | Yes| SMS message type. If the content is composed of character strings, the SMS message is a text message. If the content is composed of byte arrays, the SMS message is a data message.| | content | string \| Array&lt;number&gt; | Yes | SMS message type. If the content is composed of character strings, the SMS message is a text message. If the content is composed of byte arrays, the SMS message is a data message.|
| serviceCenter | string | No| SMSC address. By default, the SMSC address in the SIM card is used.| | serviceCenter | string | No | SMSC address. By default, the SMSC address in the SIM card is used. |
| destinationPort | number | No| Destination port of the SMS message. This parameter is mandatory only for a data message. Otherwise, it is optional.| | destinationPort | number | No | Destination port of the SMS message. This parameter is mandatory only for a data message. Otherwise, it is optional. |
| sendCallback | AsyncCallback&lt;[ISendShortMessageCallback](#ISendShortMessageCallback)&gt; | No| Callback used to return the SMS message sending result. For details, see [ISendShortMessageCallback](#ISendShortMessageCallback).| | sendCallback | AsyncCallback&lt;[ISendShortMessageCallback](#ISendShortMessageCallback)&gt; | No | Callback used to return the SMS message sending result. For details, see [ISendShortMessageCallback](#ISendShortMessageCallback).|
| deliveryCallback | AsyncCallback&lt;[IDeliveryShortMessageCallback](#IDeliveryShortMessageCallback)&gt; | No| Callback used to return the SMS message delivery report. For details, see [IDeliveryShortMessageCallback](#IDeliveryShortMessageCallback).| | deliveryCallback | AsyncCallback&lt;[IDeliveryShortMessageCallback](#IDeliveryShortMessageCallback)&gt; | No | Callback used to return the SMS message delivery report. For details, see [IDeliveryShortMessageCallback](#IDeliveryShortMessageCallback).|
## ISendShortMessageCallback<a name=ISendShortMessageCallback></a> ## ISendShortMessageCallback<a name=ISendShortMessageCallback></a>
...@@ -348,11 +366,11 @@ Provides the callback for the SMS message sending result. It consists of three p ...@@ -348,11 +366,11 @@ Provides the callback for the SMS message sending result. It consists of three p
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Name| Type| Mandatory| Description| | Parameter | Type | Mandatory| Description |
| ---------- | ------------------------------- | ---- | ------------------------------------------------------------ | | ---------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| isLastPart | boolean | No| Whether this SMS message is the last part of a long SMS message. The value **true** indicates that this SMS message is the last part of a long SMS message, and value **false** indicates the opposite. The default value is **false**.| | isLastPart | boolean | No | Whether this SMS message is the last part of a long SMS message. The value **true** indicates that this SMS message is the last part of a long SMS message, and value **false** indicates the opposite. The default value is **false**.|
| result | [SendSmsResult](#SendSmsResult) | Yes| SMS message sending result.| | result | [SendSmsResult](#SendSmsResult) | Yes | SMS message sending result. |
| url | string | Yes| URI for storing sent SMS messages.| | url | string | Yes | URI for storing sent SMS messages. |
## IDeliveryShortMessageCallback<a name=IDeliveryShortMessageCallback></a> ## IDeliveryShortMessageCallback<a name=IDeliveryShortMessageCallback></a>
...@@ -361,9 +379,9 @@ Provides the callback for the SMS message sending result. Return the SMS deliver ...@@ -361,9 +379,9 @@ Provides the callback for the SMS message sending result. Return the SMS deliver
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Name| Type| Mandatory| Description| | Parameter| Type | Mandatory| Description |
| ------ | ------------------- | ---- | -------------- | | ------ | ------------------- | ---- | -------------- |
| pdu | Array&lt;number&gt; | Yes| SMS message delivery report.| | pdu | Array&lt;number&gt; | Yes | SMS message delivery report.|
## SendSmsResult<a name=SendSmsResult></a> ## SendSmsResult<a name=SendSmsResult></a>
...@@ -372,9 +390,9 @@ Enumerates SMS message sending results. ...@@ -372,9 +390,9 @@ Enumerates SMS message sending results.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Name| Value| Description| | Parameter | Value | Description |
| ------------------------------------ | ---- | ------------------------------------------------------ | | ------------------------------------ | ---- | ------------------------------------------------------ |
| SEND_SMS_SUCCESS | 0 | SMS message sent successfully.| | SEND_SMS_SUCCESS | 0 | SMS message sent successfully. |
| SEND_SMS_FAILURE_UNKNOWN | 1 | Failed to send the SMS message due to unknown reasons.| | SEND_SMS_FAILURE_UNKNOWN | 1 | Failed to send the SMS message due to unknown reasons. |
| SEND_SMS_FAILURE_RADIO_OFF | 2 | Failed to send the SMS message because the modem is shut down.| | SEND_SMS_FAILURE_RADIO_OFF | 2 | Failed to send the SMS message because the modem is shut down. |
| SEND_SMS_FAILURE_SERVICE_UNAVAILABLE | 3 | Failed to send the SMS message because the network is unavailable or SMS message sending or receiving is not supported.| | SEND_SMS_FAILURE_SERVICE_UNAVAILABLE | 3 | Failed to send the SMS message because the network is unavailable or SMS message sending or receiving is not supported.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册