js-apis-sms.md 90.4 KB
Newer Older
S
shawn_he 已提交
1
# @ohos.telephony.sms (SMS)
S
shawn_he 已提交
2

S
shawn_he 已提交
3
The **sms** module provides basic SMS management functions. You can create and send SMS messages, and obtain and set the default SIM card for sending and receiving SMS messages. Besides, you can obtain and set the SMSC address, and check whether the current device can send and receive SMS messages.
S
shawn_he 已提交
4

S
shawn_he 已提交
5
>**NOTE**
S
shawn_he 已提交
6
>
Z
zengyawen 已提交
7
>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 已提交
8 9 10

## Modules to Import

S
shawn_he 已提交
11
```js
S
shawn_he 已提交
12 13 14
import sms from '@ohos.telephony.sms';
```

S
shawn_he 已提交
15
## sms.createMessage
S
shawn_he 已提交
16

S
shawn_he 已提交
17
createMessage\(pdu: Array&lt;number&gt;, specification: string, callback: AsyncCallback\<ShortMessage\>\): void
S
shawn_he 已提交
18

S
shawn_he 已提交
19
Creates an SMS instance based on the protocol data unit (PDU) and specified SMS protocol. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
20

S
shawn_he 已提交
21 22
**System capability**: SystemCapability.Telephony.SmsMms

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

S
shawn_he 已提交
25
| Name       | Type                                              | Mandatory| Description                                                        |
S
shawn_he 已提交
26
| ------------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
27
| pdu           | Array&lt;number&gt;                                | Yes  | Protocol data unit, which is obtained from the received SMS message.                          |
S
shawn_he 已提交
28
| specification | string                                             | Yes  | SMS protocol type. <br>- **3gpp**: GSM/UMTS/LTE SMS<br>- **3gpp2**: CDMA SMS|
S
shawn_he 已提交
29
| callback      | AsyncCallback&lt;[ShortMessage](#shortmessage)&gt; | Yes  | Callback used to return the result.                                                  |
S
shawn_he 已提交
30

S
shawn_he 已提交
31 32 33 34 35 36 37 38 39 40 41 42
**Error codes**

For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

| ID|                  Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
43
**Example**
S
shawn_he 已提交
44

S
shawn_he 已提交
45
```js
S
shawn_he 已提交
46 47 48 49 50 51 52
const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91];
sms.createMessage(pdu, specification, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
53 54


S
shawn_he 已提交
55
## sms.createMessage
S
shawn_he 已提交
56

S
shawn_he 已提交
57
createMessage\(pdu: Array&lt;number&gt;, specification: string\): Promise\<ShortMessage\>
S
shawn_he 已提交
58

S
shawn_he 已提交
59
Creates an SMS instance based on the PDU and specified SMS protocol. This API uses a promise to return the result.
S
shawn_he 已提交
60

S
shawn_he 已提交
61 62
**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
63
**Parameters**
S
shawn_he 已提交
64

S
shawn_he 已提交
65
| Name       | Type               | Mandatory| Description                                                        |
S
shawn_he 已提交
66
| ------------- | ------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
67
| pdu           | Array&lt;number&gt; | Yes  | Protocol data unit, which is obtained from the received SMS message.                          |
S
shawn_he 已提交
68
| specification | string              | Yes  | SMS protocol type. <br>- **3gpp**: GSM/UMTS/LTE SMS<br>- **3gpp2**: CDMA SMS|
S
shawn_he 已提交
69

S
shawn_he 已提交
70
**Return value**
S
shawn_he 已提交
71

S
shawn_he 已提交
72
| Type                                        | Description                             |
S
shawn_he 已提交
73
| -------------------------------------------- | --------------------------------- |
S
shawn_he 已提交
74
| Promise&lt;[ShortMessage](#shortmessage)&gt; | Promise used to return the result.|
S
shawn_he 已提交
75

S
shawn_he 已提交
76 77 78 79 80 81 82 83 84 85 86 87
**Error codes**

For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

| ID|                  Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
88
**Example**
S
shawn_he 已提交
89

S
shawn_he 已提交
90
```js
S
shawn_he 已提交
91 92 93 94 95 96 97
const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91];
let promise = sms.createMessage(pdu, specification);
promise.then(data => {
    console.log(`createMessage success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
98
    console.error(`createMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
99 100
});
```
S
shawn_he 已提交
101

S
shawn_he 已提交
102
## sms.sendMessage<sup>(deprecated)</sup>
S
shawn_he 已提交
103

S
shawn_he 已提交
104
sendMessage\(options: SendMessageOptions\): void
S
shawn_he 已提交
105 106 107

Sends an SMS message.

S
shawn_he 已提交
108 109 110 111
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 10. You are advised to use [sendShortMessage](#smssendshortmessage10).

S
shawn_he 已提交
112
**Required permissions**: ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
113 114

**System capability**: SystemCapability.Telephony.SmsMms
S
shawn_he 已提交
115

S
shawn_he 已提交
116
**Parameters**
S
shawn_he 已提交
117

S
shawn_he 已提交
118
| Name | Type                                     | Mandatory| Description                                                        |
S
shawn_he 已提交
119
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
120
| options | [SendMessageOptions](#sendmessageoptions) | Yes  | Options (including the callback) for sending an SMS message.|
S
shawn_he 已提交
121

S
shawn_he 已提交
122 123 124 125 126 127 128 129 130 131 132 133 134
**Error codes**

For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
135
**Example**
S
shawn_he 已提交
136

S
shawn_he 已提交
137
```js
138
let sendCallback = function (err, data) {
S
shawn_he 已提交
139 140
    console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 
}
141
let deliveryCallback = function (err, data) {
S
shawn_he 已提交
142 143 144 145 146 147 148 149 150 151
    console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 
}
let slotId = 0;
let content ='SMS message content';
let destinationHost = '+861xxxxxxxxxx';
let serviceCenter = '+861xxxxxxxxxx';
let destinationPort = 1000;
let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback};
sms.sendMessage(options);
```
S
shawn_he 已提交
152

S
shawn_he 已提交
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
## sms.sendShortMessage<sup>10+</sup>

sendShortMessage\(options: SendMessageOptions, callback: AsyncCallback&lt;void&gt;\): void

Sends an SMS message. This API uses an asynchronous callback to return the result.

**Required permissions**: ohos.permission.SEND_MESSAGES

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                       | Mandatory| Description                                    |
| -------- | --------------------------- | ---- | ---------------------------------------- |
| options | [SendMessageOptions](#sendmessageoptions) | Yes  | Options (including the callback) for sending an SMS message.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|

**Error codes**

For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

**Example**

```js
let sendCallback = function (err, data) {
    console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
let deliveryCallback = function (err, data) {
    console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
let slotId = 0;
let content ='SMS message content';
let destinationHost = '+861xxxxxxxxxx';
let serviceCenter = '+861xxxxxxxxxx';
let destinationPort = 1000;
let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback};
sms.sendMessage(options, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
});
```

## sms.sendShortMessage<sup>10+</sup>

sendShortMessage\(options: SendMessageOptions\): Promise&lt;void&gt;

Sends an SMS message. This API uses a promise to return the result.

**Required permissions**: ohos.permission.SEND_MESSAGES

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                       | Mandatory| Description                                    |
| -------- | --------------------------- | ---- | ---------------------------------------- |
| options | [SendMessageOptions](#sendmessageoptions) | Yes  | Options (including the callback) for sending an SMS message.|

**Return value**

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

**Error codes**

For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

**Example**

```js
let sendCallback = function (err, data) {
    console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
let deliveryCallback = function (err, data) {
    console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
let slotId = 0;
let content ='SMS message content';
let destinationHost = '+861xxxxxxxxxx';
let serviceCenter = '+861xxxxxxxxxx';
let destinationPort = 1000;
let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback};
let promise = sms.sendShortMessage(options);
promise.then(() => {
    console.log(`sendShortMessage success`);
}).catch(err => {
    console.error(`sendShortMessage failed, promise: err->${JSON.stringify(err)}`);
});

```
S
shawn_he 已提交
261

S
shawn_he 已提交
262
## sms.getDefaultSmsSlotId<sup>7+</sup>
S
shawn_he 已提交
263

S
shawn_he 已提交
264
getDefaultSmsSlotId\(callback: AsyncCallback&lt;number&gt;\): void
S
shawn_he 已提交
265

S
shawn_he 已提交
266
Obtains the default slot ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
267

S
shawn_he 已提交
268 269
**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
270
**Parameters**
S
shawn_he 已提交
271

S
shawn_he 已提交
272
| Name  | Type                       | Mandatory| Description                                    |
S
shawn_he 已提交
273
| -------- | --------------------------- | ---- | ---------------------------------------- |
S
shawn_he 已提交
274
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
275

S
shawn_he 已提交
276
**Example**
S
shawn_he 已提交
277

S
shawn_he 已提交
278
```js
S
shawn_he 已提交
279 280 281 282
sms.getDefaultSmsSlotId((err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
283 284


S
shawn_he 已提交
285
## sms.getDefaultSmsSlotId<sup>7+</sup>
S
shawn_he 已提交
286

S
shawn_he 已提交
287
getDefaultSmsSlotId\(\): Promise&lt;number&gt;
S
shawn_he 已提交
288

S
shawn_he 已提交
289
Obtains the default slot ID of the SIM card used to send SMS messages. This API uses a promise to return the result.
S
shawn_he 已提交
290

S
shawn_he 已提交
291 292
**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
293
**Return value**
S
shawn_he 已提交
294

S
shawn_he 已提交
295
| Type           | Description                                                        |
S
shawn_he 已提交
296
| --------------- | ------------------------------------------------------------ |
S
shawn_he 已提交
297
| Promise&lt;number&gt; | Promise used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
298

S
shawn_he 已提交
299
**Example**
S
shawn_he 已提交
300

S
shawn_he 已提交
301
```js
S
shawn_he 已提交
302
let promise = sms.getDefaultSmsSlotId();
S
shawn_he 已提交
303 304 305
promise.then(data => {
    console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
306
    console.error(`getDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
307 308
});
```
S
shawn_he 已提交
309

S
shawn_he 已提交
310 311
## sms.setDefaultSmsSlotId<sup>7+</sup>

S
shawn_he 已提交
312
setDefaultSmsSlotId\(slotId: number, callback: AsyncCallback&lt;void&gt;\): void
S
shawn_he 已提交
313

S
shawn_he 已提交
314
Sets the default slot ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
315

S
shawn_he 已提交
316
**System API**: This is a system API.
S
shawn_he 已提交
317

S
shawn_he 已提交
318
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE
S
shawn_he 已提交
319 320 321 322 323 324 325

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                     | Mandatory| Description                                                        |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
326
| slotId   | number                    | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
S
shawn_he 已提交
327 328
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                                  |

S
shawn_he 已提交
329 330
**Error codes**

S
shawn_he 已提交
331 332
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
333 334 335
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
336
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
337 338 339 340 341 342 343
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
344 345 346
**Example**

```js
S
shawn_he 已提交
347 348
sms.setDefaultSmsSlotId(0, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}.`);
S
shawn_he 已提交
349 350 351 352 353 354 355 356
});
```


## sms.setDefaultSmsSlotId<sup>7+</sup>

setDefaultSmsSlotId\(slotId: number\): Promise&lt;void&gt;

S
shawn_he 已提交
357
Sets the default slot ID of the SIM card used to send SMS messages. This API uses a promise to return the result.
S
shawn_he 已提交
358

S
shawn_he 已提交
359
**System API**: This is a system API.
S
shawn_he 已提交
360

S
shawn_he 已提交
361
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE
S
shawn_he 已提交
362 363 364 365 366 367 368

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name| Type  | Mandatory| Description                                                        |
| ------ | ------ | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
369
| slotId | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
S
shawn_he 已提交
370 371 372

**Return value**

S
shawn_he 已提交
373 374 375 376 377 378
| Type           | Description                           |
| --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.|

**Error codes**

S
shawn_he 已提交
379 380
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
381 382 383
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
384
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
385 386 387 388 389 390
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
S
shawn_he 已提交
391 392 393 394 395

**Example**

```js
let promise = sms.setDefaultSmsSlotId(0);
S
shawn_he 已提交
396 397 398
promise.then(() => {
    console.log(`setDefaultSmsSlotId success.`);
}).catch((err) => {
S
shawn_he 已提交
399
    console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
400 401
});
```
S
shawn_he 已提交
402

S
shawn_he 已提交
403
## sms.setSmscAddr<sup>7+</sup>
S
shawn_he 已提交
404

S
shawn_he 已提交
405
setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
406

S
shawn_he 已提交
407
Sets the short message service center (SMSC) address. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
408

S
shawn_he 已提交
409
**System API**: This is a system API.
S
shawn_he 已提交
410

S
shawn_he 已提交
411
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
412 413

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

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

S
shawn_he 已提交
417
| Name  | Type                     | Mandatory| Description                                     |
S
shawn_he 已提交
418
| -------- | ------------------------- | ---- | ----------------------------------------- |
S
shawn_he 已提交
419
| slotId   | number                    | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
420
| smscAddr | string                    | Yes  | SMSC address.                       |
S
shawn_he 已提交
421
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                               |
S
shawn_he 已提交
422

S
shawn_he 已提交
423 424
**Error codes**

S
shawn_he 已提交
425 426
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
427 428 429
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
430
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
431 432 433 434 435 436
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
437
**Example**
S
shawn_he 已提交
438

S
shawn_he 已提交
439
```js
S
shawn_he 已提交
440 441
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
S
shawn_he 已提交
442 443
sms.setSmscAddr(slotId, smscAddr, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
444 445
});
```
S
shawn_he 已提交
446 447


S
shawn_he 已提交
448
## sms.setSmscAddr<sup>7+</sup>
S
shawn_he 已提交
449

S
shawn_he 已提交
450
setSmscAddr\(slotId: number, smscAddr: string\): Promise\<void\>
S
shawn_he 已提交
451

S
shawn_he 已提交
452
Sets the SMSC address. This API uses a promise to return the result.
S
shawn_he 已提交
453

S
shawn_he 已提交
454
**System API**: This is a system API.
S
shawn_he 已提交
455

S
shawn_he 已提交
456
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
457 458

**System capability**: SystemCapability.Telephony.SmsMms
S
shawn_he 已提交
459

S
shawn_he 已提交
460
**Parameters**
S
shawn_he 已提交
461

S
shawn_he 已提交
462
| Name  | Type  | Mandatory| Description                                     |
S
shawn_he 已提交
463
| -------- | ------ | ---- | ----------------------------------------- |
S
shawn_he 已提交
464
| slotId   | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
465
| smscAddr | string | Yes  | SMSC address.                       |
S
shawn_he 已提交
466

S
shawn_he 已提交
467
**Return value**
S
shawn_he 已提交
468

S
shawn_he 已提交
469
| Type               | Description                           |
S
shawn_he 已提交
470 471
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
S
shawn_he 已提交
472

S
shawn_he 已提交
473 474
**Error codes**

S
shawn_he 已提交
475 476
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
477 478 479
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
480
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
481 482 483 484 485 486
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
487
**Example**
S
shawn_he 已提交
488

S
shawn_he 已提交
489
```js
S
shawn_he 已提交
490 491 492
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
let promise = sms.setSmscAddr(slotId, smscAddr);
S
shawn_he 已提交
493 494 495
promise.then(() => {
    console.log(`setSmscAddr success.`);
}).catch((err) => {
S
shawn_he 已提交
496
    console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
497 498
});
```
S
shawn_he 已提交
499 500


S
shawn_he 已提交
501
## sms.getSmscAddr<sup>7+</sup>
S
shawn_he 已提交
502

S
shawn_he 已提交
503
getSmscAddr\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
504

S
shawn_he 已提交
505
Obtains the SMSC address. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
506

S
shawn_he 已提交
507
**System API**: This is a system API.
S
shawn_he 已提交
508

S
shawn_he 已提交
509
**Required permissions**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
510 511

**System capability**: SystemCapability.Telephony.SmsMms
S
shawn_he 已提交
512

S
shawn_he 已提交
513
**Parameters**
S
shawn_he 已提交
514

S
shawn_he 已提交
515
| Name  | Type                       | Mandatory| Description                                     |
S
shawn_he 已提交
516
| -------- | --------------------------- | ---- | ----------------------------------------- |
S
shawn_he 已提交
517 518
| 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.                               |
S
shawn_he 已提交
519

S
shawn_he 已提交
520 521
**Error codes**

S
shawn_he 已提交
522 523
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
524 525 526
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
527
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
528 529 530 531 532 533
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
534
**Example**
S
shawn_he 已提交
535

S
shawn_he 已提交
536
```js
S
shawn_he 已提交
537 538 539 540 541
let slotId = 0;
sms.getSmscAddr(slotId, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
542 543


S
shawn_he 已提交
544
## sms.getSmscAddr<sup>7+</sup>
S
shawn_he 已提交
545

S
shawn_he 已提交
546
getSmscAddr\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
547

S
shawn_he 已提交
548
Obtains the SMSC address. This API uses a promise to return the result.
S
shawn_he 已提交
549

S
shawn_he 已提交
550
**System API**: This is a system API.
S
shawn_he 已提交
551

S
shawn_he 已提交
552
**Required permissions**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
553 554

**System capability**: SystemCapability.Telephony.SmsMms
S
shawn_he 已提交
555

S
shawn_he 已提交
556
**Parameters**
S
shawn_he 已提交
557

S
shawn_he 已提交
558
| Name| Type  | Mandatory| Description                                     |
S
shawn_he 已提交
559
| ------ | ------ | ---- | ----------------------------------------- |
S
shawn_he 已提交
560
| slotId | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
561

S
shawn_he 已提交
562
**Return value**
S
shawn_he 已提交
563

S
shawn_he 已提交
564
| Type                 | Description                                         |
S
shawn_he 已提交
565 566
| --------------------- | --------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.|
S
shawn_he 已提交
567

S
shawn_he 已提交
568 569
**Error codes**

S
shawn_he 已提交
570 571
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
572 573 574
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
575
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
576 577 578 579 580 581
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
582
**Example**
S
shawn_he 已提交
583

S
shawn_he 已提交
584
```js
S
shawn_he 已提交
585 586 587 588 589
let slotId = 0;
let promise = sms.getSmscAddr(slotId);
promise.then(data => {
    console.log(`getSmscAddr success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
590
    console.error(`getSmscAddr failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
591 592
});
```
S
shawn_he 已提交
593

S
shawn_he 已提交
594
## sms.hasSmsCapability<sup>7+</sup>
S
shawn_he 已提交
595

S
shawn_he 已提交
596
hasSmsCapability\(\): boolean
S
shawn_he 已提交
597

S
shawn_he 已提交
598
Checks whether the current device can send and receive SMS messages. This API works in synchronous mode.
S
shawn_he 已提交
599 600 601

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
602
**Return value**
S
shawn_he 已提交
603 604 605 606 607

| Type   | Description                                                        |
| ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.|

S
shawn_he 已提交
608
```js
S
shawn_he 已提交
609 610 611
let result = sms.hasSmsCapability(); 
console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
```
S
shawn_he 已提交
612

S
shawn_he 已提交
613 614
## sms.splitMessage<sup>8+</sup>

S
shawn_he 已提交
615
splitMessage\(content: string, callback: AsyncCallback\<Array\<string\>\>\): void
S
shawn_he 已提交
616 617 618

Splits an SMS message into multiple segments. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
619
**System API**: This is a system API.
S
shawn_he 已提交
620

S
shawn_he 已提交
621
**Required permissions**: ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
622 623 624 625 626 627 628 629 630 631

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                         | Mandatory| Description                         |
| -------- | ----------------------------- | ---- | ----------------------------- |
| content  | string                        | Yes  | SMS message content. The value cannot be null.|
| callback | AsyncCallback<Array<string\>> | Yes  | Callback used to return the result.                   |

S
shawn_he 已提交
632 633
**Error codes**

S
shawn_he 已提交
634 635
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
636 637 638
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
639
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
640 641 642 643 644 645
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
646 647 648
**Example**

```js
S
shawn_he 已提交
649
let content = "long message";
S
shawn_he 已提交
650 651 652 653 654 655 656 657
sms.splitMessage(content, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sms.splitMessage<sup>8+</sup>

S
shawn_he 已提交
658
splitMessage\(content: string\): Promise\<Array\<string\>\>
S
shawn_he 已提交
659 660 661

Splits an SMS message into multiple segments. This API uses a promise to return the result.

S
shawn_he 已提交
662
**System API**: This is a system API.
S
shawn_he 已提交
663

S
shawn_he 已提交
664
**Required permissions**: ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name | Type  | Mandatory| Description                        |
| ------- | ------ | ---- | ---------------------------- |
| content | string | Yes  | SMS message content. The value cannot be null.|

**Return value**

| Type                   | Description                               |
| ----------------------- | ----------------------------------- |
| Promise<Array<string\>> | Promise used to return the result.|

S
shawn_he 已提交
680 681
**Error codes**

S
shawn_he 已提交
682 683
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
684 685 686
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
687
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
688 689 690 691 692 693
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
694 695 696
**Example**

```js
S
shawn_he 已提交
697
let content = "long message";
S
shawn_he 已提交
698 699 700 701
let promise = sms.splitMessage(content);
promise.then(data => {
    console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
702
    console.error(`splitMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
703 704 705 706 707
});
```

## sms.addSimMessage<sup>7+</sup>

S
shawn_he 已提交
708
addSimMessage\(options: SimMessageOptions, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
709 710 711

Adds a SIM message. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
712
**System API**: This is a system API.
S
shawn_he 已提交
713

S
shawn_he 已提交
714
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
715 716 717 718 719 720 721 722 723 724

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                                    | Mandatory| Description           |
| -------- | ---------------------------------------- | ---- | --------------- |
| options  | [SimMessageOptions](#simmessageoptions7) | Yes  | SIM message options.|
| callback | AsyncCallback&lt;void&gt;                | Yes  | Callback used to return the result.     |

S
shawn_he 已提交
725 726
**Error codes**

S
shawn_he 已提交
727 728
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
729 730 731
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
732
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
733 734 735 736 737 738
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
739 740 741 742
**Example**

```js
let simMessageOptions = {
S
shawn_he 已提交
743 744 745 746
    slotId: 0,
    smsc: "test",
    pdu: "xxxxxx",
    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
S
shawn_he 已提交
747
};
S
shawn_he 已提交
748 749
sms.addSimMessage(simMessageOptions, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
750 751 752 753 754 755
});
```


## sms.addSimMessage<sup>7+</sup>

S
shawn_he 已提交
756
addSimMessage\(options: SimMessageOptions\): Promise\<void\>
S
shawn_he 已提交
757 758 759

Adds a SIM message. This API uses a promise to return the result.

S
shawn_he 已提交
760
**System API**: This is a system API.
S
shawn_he 已提交
761

S
shawn_he 已提交
762
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name | Type                                    | Mandatory| Description           |
| ------- | ---------------------------------------- | ---- | --------------- |
| options | [SimMessageOptions](#simmessageoptions7) | Yes  | SIM message options.|

**Return value**

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

S
shawn_he 已提交
778 779
**Error codes**

S
shawn_he 已提交
780 781
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
782 783 784
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
785
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
786 787 788 789 790 791
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
792 793 794 795
**Example**

```js
let simMessageOptions = {
S
shawn_he 已提交
796 797 798 799
    slotId: 0,
    smsc: "test",
    pdu: "xxxxxx",
    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
S
shawn_he 已提交
800 801
};
let promise = sms.addSimMessage(simMessageOptions);
S
shawn_he 已提交
802 803 804
promise.then(() => {
    console.log(`addSimMessage success.`);
}).catch((err) => {
S
shawn_he 已提交
805
    console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
806 807 808 809 810
});
```

## sms.delSimMessage<sup>7+</sup>

S
shawn_he 已提交
811
delSimMessage\(slotId: number, msgIndex: number, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
812 813 814

Deletes a SIM message. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
815
**System API**: This is a system API.
S
shawn_he 已提交
816

S
shawn_he 已提交
817
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
818 819 820 821 822 823 824 825 826 827 828

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                     | Mandatory| Description                                     |
| -------- | ------------------------- | ---- | ----------------------------------------- |
| slotId   | number                    | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| msgIndex | number                    | Yes  | Message index.                                 |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                               |

S
shawn_he 已提交
829 830
**Error codes**

S
shawn_he 已提交
831 832
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
833 834 835
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
836
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
837 838 839 840 841 842
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
843 844 845 846 847
**Example**

```js
let slotId = 0;
let msgIndex = 1;
S
shawn_he 已提交
848 849
sms.delSimMessage(slotId, msgIndex, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
850 851 852 853 854 855
});
```


## sms.delSimMessage<sup>7+</sup>

S
shawn_he 已提交
856
delSimMessage\(slotId: number, msgIndex: number\): Promise\<void\>
S
shawn_he 已提交
857 858 859

Deletes a SIM message. This API uses a promise to return the result.

S
shawn_he 已提交
860
**System API**: This is a system API.
S
shawn_he 已提交
861

S
shawn_he 已提交
862
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type  | Mandatory| Description                                     |
| -------- | ------ | ---- | ----------------------------------------- |
| slotId   | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| msgIndex | number | Yes  | Message index.                                 |

**Return value**

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

S
shawn_he 已提交
879 880
**Error codes**

S
shawn_he 已提交
881 882
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
883 884 885
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
886
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
887 888 889 890 891 892
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
893 894 895 896 897 898
**Example**

```js
let slotId = 0;
let msgIndex = 1;
let promise = sms.delSimMessage(slotId, msgIndex);
S
shawn_he 已提交
899 900 901
promise.then(() => {
    console.log(`delSimMessage success.`);
}).catch((err) => {
S
shawn_he 已提交
902
    console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
903 904 905 906 907
});
```

## sms.updateSimMessage<sup>7+</sup>

S
shawn_he 已提交
908
updateSimMessage\(options: UpdateSimMessageOptions, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
909 910 911

Updates a SIM message. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
912
**System API**: This is a system API.
S
shawn_he 已提交
913

S
shawn_he 已提交
914
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
915 916 917 918 919 920 921 922 923 924

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                                                | Mandatory| Description               |
| -------- | ---------------------------------------------------- | ---- | ------------------- |
| options  | [UpdateSimMessageOptions](#updatesimmessageoptions7) | Yes  | SIM message updating options.|
| callback | AsyncCallback&lt;void&gt;                            | Yes  | Callback used to return the result.         |

S
shawn_he 已提交
925 926
**Error codes**

S
shawn_he 已提交
927 928
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
929 930 931
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
932
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
933 934 935 936 937 938
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
939 940 941 942
**Example**

```js
let updateSimMessageOptions = {
S
shawn_he 已提交
943 944 945
    slotId: 0,
    msgIndex: 1,
    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
S
shawn_he 已提交
946 947
    pdu: "xxxxxxx",
    smsc: "test"
S
shawn_he 已提交
948
};
S
shawn_he 已提交
949 950
sms.updateSimMessage(updateSimMessageOptions, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
951 952 953 954 955 956
});
```


## sms.updateSimMessage<sup>7+</sup>

S
shawn_he 已提交
957
updateSimMessage\(options: UpdateSimMessageOptions\): Promise\<void\>
S
shawn_he 已提交
958 959 960

Updates a SIM message. This API uses a promise to return the result.

S
shawn_he 已提交
961
**System API**: This is a system API.
S
shawn_he 已提交
962

S
shawn_he 已提交
963
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
964 965 966 967 968 969 970 971 972 973 974 975 976 977 978

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name | Type                                                | Mandatory| Description               |
| ------- | ---------------------------------------------------- | ---- | ------------------- |
| options | [UpdateSimMessageOptions](#updatesimmessageoptions7) | Yes  | SIM message updating options.|

**Return value**

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

S
shawn_he 已提交
979 980
**Error codes**

S
shawn_he 已提交
981 982
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
983 984 985
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
986
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
987 988 989 990 991 992
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
993 994 995 996
**Example**

```js
let updateSimMessageOptions = {
S
shawn_he 已提交
997 998 999
    slotId: 0,
    msgIndex: 1,
    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
S
shawn_he 已提交
1000 1001
    pdu: "xxxxxxx",
    smsc: "test"
S
shawn_he 已提交
1002 1003
};
let promise = sms.updateSimMessage(updateSimMessageOptions);
S
shawn_he 已提交
1004 1005 1006
promise.then(() => {
    console.log(`updateSimMessage success.`);
}).catch((err) => {
S
shawn_he 已提交
1007
    console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1008 1009 1010 1011 1012
});
```

## sms.getAllSimMessages<sup>7+</sup>

S
shawn_he 已提交
1013
getAllSimMessages\(slotId: number, callback: AsyncCallback\<Array\<SimShortMessage\>\>\): void
S
shawn_he 已提交
1014 1015 1016

Obtains all SIM card messages. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1017
**System API**: This is a system API.
S
shawn_he 已提交
1018

S
shawn_he 已提交
1019
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
1020 1021 1022 1023 1024 1025 1026 1027

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                                                       | Mandatory| Description                                     |
| -------- | ----------------------------------------------------------- | ---- | ----------------------------------------- |
| slotId   | number                                                      | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
1028
| callback | AsyncCallback<Array<[SimShortMessage](#simshortmessage7)\>> | Yes  | Callback used to return the result.                               |
S
shawn_he 已提交
1029

S
shawn_he 已提交
1030 1031
**Error codes**

S
shawn_he 已提交
1032 1033
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1034 1035 1036
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1037
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1038 1039 1040 1041 1042 1043
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055
**Example**

```js
let slotId = 0;
sms.getAllSimMessages(slotId, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sms.getAllSimMessages<sup>7+</sup>

S
shawn_he 已提交
1056
getAllSimMessages\(slotId: number\): Promise\<Array\<SimShortMessage\>\>
S
shawn_he 已提交
1057 1058 1059

Obtains all SIM card messages. This API uses a promise to return the result.

S
shawn_he 已提交
1060
**System API**: This is a system API.
S
shawn_he 已提交
1061

S
shawn_he 已提交
1062
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name| Type  | Mandatory| Description                                     |
| ------ | ------ | ---- | ----------------------------------------- |
| slotId | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

| Type                                                   | Description                              |
| ------------------------------------------------------- | ---------------------------------- |
S
shawn_he 已提交
1076
| PromiseArray<[SimShortMessage](#simshortmessage7)\>&gt; | Promise used to return the result.|
S
shawn_he 已提交
1077

S
shawn_he 已提交
1078 1079
**Error codes**

S
shawn_he 已提交
1080 1081
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1082 1083 1084
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1085
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1086 1087 1088 1089 1090 1091
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1092 1093 1094 1095 1096 1097 1098 1099
**Example**

```js
let slotId = 0;
let promise = sms.getAllSimMessages(slotId);
promise.then(data => {
    console.log(`getAllSimMessages success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1100
    console.error(`getAllSimMessages failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1101 1102 1103 1104 1105
});
```

## sms.setCBConfig<sup>7+</sup>

S
shawn_he 已提交
1106
setCBConfig\(options: CBConfigOptions, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
1107 1108 1109

Sets the cell broadcast configuration. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1110
**System API**: This is a system API.
S
shawn_he 已提交
1111

S
shawn_he 已提交
1112
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
1113 1114 1115 1116 1117 1118 1119

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                                | Mandatory| Description        |
| -------- | ------------------------------------ | ---- | ------------ |
S
shawn_he 已提交
1120
| options  | [CBConfigOptions](#cbconfigoptions7) | Yes  | Cell broadcast configuration options.|
S
shawn_he 已提交
1121 1122
| callback | AsyncCallback&lt;void&gt;            | Yes  | Callback used to return the result.  |

S
shawn_he 已提交
1123 1124
**Error codes**

S
shawn_he 已提交
1125 1126
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1127 1128 1129
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1130
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1131 1132 1133 1134 1135 1136
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1137 1138 1139 1140
**Example**

```js
let cbConfigOptions = {
S
shawn_he 已提交
1141 1142 1143 1144 1145
    slotId: 0,
    enable: true,
    startMessageId: 100,
    endMessageId: 200,
    ranType: sms.RanType.TYPE_GSM
S
shawn_he 已提交
1146
};
S
shawn_he 已提交
1147 1148
sms.setCBConfig(cbConfigOptions, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1149 1150 1151 1152 1153 1154
});
```


## sms.setCBConfig<sup>7+</sup>

S
shawn_he 已提交
1155
setCBConfig\(options: CBConfigOptions\): Promise\<void\>
S
shawn_he 已提交
1156 1157 1158

Sets the cell broadcast configuration. This API uses a promise to return the result.

S
shawn_he 已提交
1159
**System API**: This is a system API.
S
shawn_he 已提交
1160

S
shawn_he 已提交
1161
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
1162 1163 1164 1165 1166 1167 1168

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name | Type                                | Mandatory| Description        |
| ------- | ------------------------------------ | ---- | ------------ |
S
shawn_he 已提交
1169
| options | [CBConfigOptions](#cbconfigoptions7) | Yes  | Cell broadcast configuration options.|
S
shawn_he 已提交
1170 1171 1172 1173 1174 1175 1176

**Return value**

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

S
shawn_he 已提交
1177 1178
**Error codes**

S
shawn_he 已提交
1179 1180
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1181 1182 1183
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1184
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1185 1186 1187 1188 1189 1190
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1191 1192 1193 1194
**Example**

```js
let cbConfigOptions = {
S
shawn_he 已提交
1195 1196 1197 1198 1199
    slotId: 0,
    enable: true,
    startMessageId: 100,
    endMessageId: 200,
    ranType: sms.RanType.TYPE_GSM
S
shawn_he 已提交
1200 1201
};
let promise = sms.setCBConfig(cbConfigOptions);
S
shawn_he 已提交
1202 1203 1204
promise.then(() => {
    console.log(`setCBConfig success.`);
}).catch((err) => {
S
shawn_he 已提交
1205
    console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1206 1207 1208 1209 1210
});
```

## sms.getSmsSegmentsInfo<sup>8+</sup>

S
shawn_he 已提交
1211
getSmsSegmentsInfo\(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback\<SmsSegmentsInfo\>\): void
S
shawn_he 已提交
1212 1213 1214

Obtains SMS message segment information. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1215
**System API**: This is a system API.
S
shawn_he 已提交
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name   | Type                                                        | Mandatory| Description                                     |
| --------- | ------------------------------------------------------------ | ---- | ----------------------------------------- |
| slotId    | number                                                       | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| message   | string                                                       | Yes  | SMS message.                                     |
| force7bit | boolean                                                      | Yes  | Whether to use 7-bit coding.                         |
S
shawn_he 已提交
1226 1227 1228 1229
| callback  | AsyncCallback&lt;[SmsSegmentsInfo](#smssegmentsinfo8)&gt; | Yes  | Callback used to return the result.                                 |

**Error codes**

S
shawn_he 已提交
1230 1231
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1232 1233
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1234
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1235 1236 1237 1238 1239
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |
S
shawn_he 已提交
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252

**Example**

```js
let slotId = 0;
sms.getSmsSegmentsInfo(slotId, "message", false, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sms.getSmsSegmentsInfo<sup>8+</sup>

S
shawn_he 已提交
1253
getSmsSegmentsInfo\(slotId: number, message: string, force7bit: boolean\): Promise\<SmsSegmentsInfo\>
S
shawn_he 已提交
1254 1255 1256

Obtains SMS message segment information. This API uses a promise to return the result.

S
shawn_he 已提交
1257
**System API**: This is a system API.
S
shawn_he 已提交
1258 1259 1260 1261 1262 1263 1264 1265

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name   | Type   | Mandatory| Description                                     |
| --------- | ------- | ---- | ----------------------------------------- |
| slotId    | number  | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
1266
| message   | string  | Yes  | SMS message.                                     |
S
shawn_he 已提交
1267 1268 1269 1270 1271 1272
| force7bit | boolean | Yes  | Whether to use 7-bit coding.                         |

**Return value**

| Type                                                   | Description                         |
| ------------------------------------------------------- | ----------------------------- |
S
shawn_he 已提交
1273 1274 1275 1276
| Promise&lt;[SmsSegmentsInfo](#smssegmentsinfo8)&gt; | Promise used to return the result.|

**Error codes**

S
shawn_he 已提交
1277 1278
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1279 1280
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1281
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1282 1283 1284 1285 1286
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |
S
shawn_he 已提交
1287 1288 1289 1290 1291 1292

**Example**

```js
let slotId = 0;
let promise = sms.getSmsSegmentsInfo(slotId, "message", false);
S
shawn_he 已提交
1293
promise.then(data => {
S
shawn_he 已提交
1294 1295
    console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1296
    console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1297 1298 1299 1300 1301
});
```

## sms.isImsSmsSupported<sup>8+</sup>

S
shawn_he 已提交
1302
isImsSmsSupported\(slotId: number, callback: AsyncCallback\<boolean\>\): void
S
shawn_he 已提交
1303 1304 1305

Checks whether SMS is supported on IMS. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1306
**System API**: This is a system API.
S
shawn_he 已提交
1307 1308 1309 1310 1311 1312 1313

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                        | Mandatory| Description      |
| -------- | ---------------------------- | ---- | ---------- |
S
shawn_he 已提交
1314
| slotId   | number                       | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
1315 1316
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.|

S
shawn_he 已提交
1317 1318
**Error codes**

S
shawn_he 已提交
1319 1320
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1321 1322
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1323
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1324 1325 1326 1327 1328 1329
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1330 1331 1332
**Example**

```js
S
shawn_he 已提交
1333 1334
let slotId = 0;
sms.isImsSmsSupported(slotId, (err, data) => {
S
shawn_he 已提交
1335
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
S
shawn_he 已提交
1336 1337 1338 1339 1340 1341
});
```


## sms.isImsSmsSupported<sup>8+</sup>

S
shawn_he 已提交
1342
isImsSmsSupported\(slotId: number\): Promise\<boolean\>
S
shawn_he 已提交
1343

S
shawn_he 已提交
1344
This API uses an asynchronous callback to return the result. This API uses a promise to return the result.
S
shawn_he 已提交
1345

S
shawn_he 已提交
1346
**System API**: This is a system API.
S
shawn_he 已提交
1347 1348 1349

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1350 1351 1352 1353 1354 1355
**Parameters**

| Name| Type  | Mandatory | Description                                 |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

S
shawn_he 已提交
1356 1357 1358 1359 1360 1361
**Return value**

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

S
shawn_he 已提交
1362 1363
**Error codes**

S
shawn_he 已提交
1364 1365
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1366 1367
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1368
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1369 1370 1371 1372 1373 1374
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1375 1376 1377
**Example**

```js
S
shawn_he 已提交
1378 1379
let slotId = 0;
let promise = sms.isImsSmsSupported(slotId);
S
shawn_he 已提交
1380 1381 1382
promise.then(data => {
    console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1383
    console.error(`isImsSmsSupported failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1384 1385 1386 1387 1388
});
```

## sms.getImsShortMessageFormat<sup>8+</sup>

S
shawn_he 已提交
1389
getImsShortMessageFormat\(callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
1390 1391 1392

Obtains the SMS format supported by the IMS. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1393
**System API**: This is a system API.
S
shawn_he 已提交
1394 1395 1396 1397 1398 1399 1400 1401 1402

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

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

S
shawn_he 已提交
1403 1404
**Error codes**

S
shawn_he 已提交
1405 1406
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1407 1408
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1409
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1410 1411 1412 1413 1414 1415
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426
**Example**

```js
sms.getImsShortMessageFormat((err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sms.getImsShortMessageFormat<sup>8+</sup>

S
shawn_he 已提交
1427
getImsShortMessageFormat\(\): Promise\<string\>
S
shawn_he 已提交
1428 1429 1430

Obtains the SMS format supported by the IMS. This API uses a promise to return the result.

S
shawn_he 已提交
1431
**System API**: This is a system API.
S
shawn_he 已提交
1432 1433 1434 1435 1436 1437 1438 1439 1440

**System capability**: SystemCapability.Telephony.SmsMms

**Return value**

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

S
shawn_he 已提交
1441 1442
**Error codes**

S
shawn_he 已提交
1443 1444
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1445 1446
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1447
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1448 1449 1450 1451
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1452 1453 1454 1455 1456 1457 1458
**Example**

```js
let promise = sms.getImsShortMessageFormat();
promise.then(data => {
    console.log(`getImsShortMessageFormat success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1459
    console.error(`getImsShortMessageFormat failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1460 1461 1462 1463 1464
});
```

## sms.decodeMms<sup>8+</sup>

S
shawn_he 已提交
1465
decodeMms\(mmsFilePathName: string | Array\<number\>, callback: AsyncCallback\<MmsInformation\>\): void
S
shawn_he 已提交
1466 1467 1468

Decodes MMS messages. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1469
**System API**: This is a system API.
S
shawn_he 已提交
1470 1471 1472 1473 1474 1475 1476 1477 1478 1479

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name         | Type                                                   | Mandatory| Description          |
| --------------- | ------------------------------------------------------- | ---- | -------------- |
| mmsFilePathName | string \|Array<number\>                                 | Yes  | MMS message file path.|
| callback        | AsyncCallback&lt;[MmsInformation](#mmsinformation8)&gt; | Yes  | Callback used to return the result.    |

S
shawn_he 已提交
1480 1481
**Error codes**

S
shawn_he 已提交
1482 1483
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1484 1485
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1486
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1487 1488 1489 1490 1491 1492
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504
**Example**

```js
let mmsFilePathName = "filename";
sms.decodeMms(mmsFilePathName, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sms.decodeMms<sup>8+</sup>

S
shawn_he 已提交
1505
decodeMms\(mmsFilePathName: string | Array\<number\>\): Promise\<MmsInformation\>
S
shawn_he 已提交
1506 1507 1508

Decodes MMS messages. This API uses a promise to return the result.

S
shawn_he 已提交
1509
**System API**: This is a system API.
S
shawn_he 已提交
1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name         | Type                   | Mandatory| Description          |
| --------------- | ----------------------- | ---- | -------------- |
| mmsFilePathName | string \|Array<number\> | Yes  | MMS message file path.|

**Return value**

| Type                                                     | Description                       |
| --------------------------------------------------------- | --------------------------- |
| Promise&lt;&lt;[MmsInformation](#mmsinformation8)&gt;&gt; | Promise used to return the result.|

S
shawn_he 已提交
1525 1526
**Error codes**

S
shawn_he 已提交
1527 1528
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1529 1530
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1531
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1532 1533 1534 1535 1536 1537
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1538 1539 1540 1541
**Example**

```js
let mmsFilePathName = "filename";
S
shawn_he 已提交
1542
let promise = sms.decodeMms(mmsFilePathName);
S
shawn_he 已提交
1543 1544 1545
promise.then(data => {
    console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1546
    console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1547 1548 1549 1550 1551
});
```

## sms.encodeMms<sup>8+</sup>

S
shawn_he 已提交
1552
encodeMms\(mms: MmsInformation, callback: AsyncCallback\<Array\<number\>\>\): void
S
shawn_he 已提交
1553

S
shawn_he 已提交
1554
MMS message code. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
1555

S
shawn_he 已提交
1556
**System API**: This is a system API.
S
shawn_he 已提交
1557 1558 1559 1560 1561 1562 1563 1564 1565 1566

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                               | Mandatory| Description      |
| -------- | ----------------------------------- | ---- | ---------- |
| mms      | [MmsInformation](#mmsinformation8)  | Yes  | MMS message information.|
| callback | AsyncCallback&lt;Array<number\>&gt; | Yes  | Callback used to return the result.|

S
shawn_he 已提交
1567 1568
**Error codes**

S
shawn_he 已提交
1569 1570
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1571 1572
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1573
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1574 1575 1576 1577 1578 1579
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1580 1581 1582 1583
**Example**

```js
let mmsAcknowledgeInd = {
S
shawn_he 已提交
1584 1585 1586
    transactionId: "100",
    version: sms.MmsVersionType.MMS_VERSION_1_0,
    reportAllowed: sms.ReportType.MMS_YES
S
shawn_he 已提交
1587 1588
};
let mmsInformation = {
S
shawn_he 已提交
1589 1590
    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
    mmsType: mmsAcknowledgeInd
S
shawn_he 已提交
1591 1592 1593 1594 1595 1596 1597 1598 1599
};
sms.encodeMms(mmsInformation, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sms.encodeMms<sup>8+</sup>

S
shawn_he 已提交
1600
encodeMms\(mms: MmsInformation\): Promise\<Array\<number\>\>
S
shawn_he 已提交
1601

S
shawn_he 已提交
1602
MMS message code. This API uses a promise to return the result.
S
shawn_he 已提交
1603

S
shawn_he 已提交
1604
**System API**: This is a system API.
S
shawn_he 已提交
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name| Type                              | Mandatory| Description      |
| ------ | ---------------------------------- | ---- | ---------- |
| mms    | [MmsInformation](#mmsinformation8) | Yes  | MMS message information.|

**Return value**

| Type                         | Description                               |
| ----------------------------- | ----------------------------------- |
| Promise&lt;Array<number\>&gt; | Promise used to return the result.|

S
shawn_he 已提交
1620 1621
**Error codes**

S
shawn_he 已提交
1622 1623
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1624 1625
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1626
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1627 1628 1629 1630 1631 1632
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1633 1634 1635 1636
**Example**

```js
let mmsAcknowledgeInd = {
S
shawn_he 已提交
1637 1638
    transactionId: "100",
    version: sms.MmsVersionType.MMS_VERSION_1_0,
S
shawn_he 已提交
1639
    reportAllowed: sms.ReportType.MMS_YES
S
shawn_he 已提交
1640 1641
};
let mmsInformation = {
S
shawn_he 已提交
1642
    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
S
shawn_he 已提交
1643
    mmsType: mmsAcknowledgeInd
S
shawn_he 已提交
1644 1645 1646 1647 1648
};
let promise = sms.encodeMms(mmsInformation);
promise.then(data => {
    console.log(`encodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1649
    console.error(`encodeMms failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1650 1651 1652
});
```

S
shawn_he 已提交
1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727
## sms.getDefaultSmsSimId<sup>10+</sup>

getDefaultSmsSimId\(callback: AsyncCallback&lt;number&gt;\): void

Obtains the default ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Telephony.SmsMms

**Parameters**

| Name  | Type                       | Mandatory| Description                                    |
| -------- | --------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the result.<br>The return value is bound to the SIM card and increases from 1.|

**Error codes**

For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301001  | SIM card is not activated.                   |

**Example**

```js
sms.getDefaultSmsSimId((err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sms.getDefaultSmsSimId<sup>10+</sup>

getDefaultSmsSimId\(\): Promise&lt;number&gt;

Obtains the default ID of the SIM card used to send SMS messages. This API uses a promise to return the result.

**System capability**: SystemCapability.Telephony.SmsMms

**Return value**

| Type           | Description                                                        |
| --------------- | ------------------------------------------------------------ |
| Promise&lt;number&gt; | Promise used to return the result.<br>The return value is bound to the SIM card and increases from 1.|

**Error codes**

For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301001  | SIM card is not activated.                   |

**Example**

```js
let promise = sms.getDefaultSmsSimId();
promise.then(data => {
    console.log(`getDefaultSmsSimId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.error(`getDefaultSmsSimId failed, promise: err->${JSON.stringify(err)}`);
});
```

S
shawn_he 已提交
1728
## ShortMessage
S
shawn_he 已提交
1729 1730 1731

Defines an SMS message instance.

S
shawn_he 已提交
1732 1733
**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746
|         Name            |                  Type                  | Mandatory| Description                                                        |
| ------------------------ | --------------------------------------- | ---- | ------------------------------------------------------------ |
| hasReplyPath             | boolean                                 |  Yes | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>TP-Reply-Path: The device returns a response based on the SMSC that sends the SMS message. |
| isReplaceMessage         | boolean                                 |  Yes | 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**.|
| isSmsStatusReportMessage | boolean                                 |  Yes | Whether the received SMS message is an SMS delivery report. The default value is **false**.<br>SMS delivery report: a message sent from the SMSC to show the current status of the SMS message you delivered.|
| messageClass             | [ShortMessageClass](#shortmessageclass) |  Yes | Enumerates SMS message types.                                                  |
| pdu                      | Array&lt;number&gt;                     |  Yes | PDU in the SMS message.                           |
| protocolId               | number                                  |  Yes | Protocol identifier used for delivering the SMS message.                                  |
| scAddress                | string                                  |  Yes | SMSC address.                                |
| scTimestamp              | number                                  |  Yes | SMSC timestamp.                                                |
| status                   | number                                  |  Yes | SMS message status sent by the SMSC in the **SMS-STATUS-REPORT** message.|
| visibleMessageBody       | string                                  |  Yes | SMS message body.                                                  |
| visibleRawAddress        | string                                  |  Yes | Sender address.                                                |
S
shawn_he 已提交
1747 1748


S
shawn_he 已提交
1749
## ShortMessageClass
S
shawn_he 已提交
1750

S
shawn_he 已提交
1751
Enumerates SMS message types.
S
shawn_he 已提交
1752

S
shawn_he 已提交
1753
**System capability**: SystemCapability.Telephony.SmsMms
S
shawn_he 已提交
1754

S
shawn_he 已提交
1755 1756 1757 1758 1759 1760 1761
| Name            | Value  | Description                                    |
| ---------------- | ---- | ---------------------------------------- |
| UNKNOWN          | 0    | Unknown type.                              |
| INSTANT_MESSAGE  | 1    | Instant message, which is displayed immediately after being received.              |
| OPTIONAL_MESSAGE | 2    | Message stored in the device or SIM card.             |
| SIM_MESSAGE      | 3    | Message containing SIM card information, which is to be stored in the SIM card.|
| FORWARD_MESSAGE  | 4    | Message to be forwarded to another device.              |
S
shawn_he 已提交
1762 1763


S
shawn_he 已提交
1764
## SendMessageOptions
S
shawn_he 已提交
1765

S
shawn_he 已提交
1766
Provides the options (including callbacks) for sending an SMS message. For example, you can specify the SMS message type by the optional parameter **content**.
S
shawn_he 已提交
1767

S
shawn_he 已提交
1768 1769
**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1770
|       Name      | Type                                                        | Mandatory| Description                                                        |
S
shawn_he 已提交
1771
| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
1772 1773 1774 1775
| 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.                                            |
| 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.               |
S
shawn_he 已提交
1776
| destinationPort  | number                                                       | No  | Destination port of the SMS message. This field is mandatory only for a data message. Otherwise, it is optional.  |
S
shawn_he 已提交
1777 1778
| 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).|
S
shawn_he 已提交
1779 1780


S
shawn_he 已提交
1781
## ISendShortMessageCallback
S
shawn_he 已提交
1782

S
shawn_he 已提交
1783 1784 1785
Provides the callback for the SMS message sending result. It consists of three parts: SMS message sending result, URI for storing the sent SMS message, and whether the SMS message is the last part of a long SMS message.

**System capability**: SystemCapability.Telephony.SmsMms
S
shawn_he 已提交
1786

S
shawn_he 已提交
1787 1788
|   Name    | Type                           | Mandatory|                                               Description                                        |
| ---------- | ------------------------------- | ---- | ----------------------------------------------------------------------------------------- |
S
shawn_he 已提交
1789
| 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**.|
S
shawn_he 已提交
1790 1791
| result     | [SendSmsResult](#sendsmsresult) | Yes  | SMS message sending result.                                                                            |
| url        | string                          | Yes  | URI for storing the sent SMS message.                                                                       |
S
shawn_he 已提交
1792 1793


S
shawn_he 已提交
1794
## IDeliveryShortMessageCallback
S
shawn_he 已提交
1795

S
shawn_he 已提交
1796
Provides the callback for the SMS message delivery report.
S
shawn_he 已提交
1797 1798

**System capability**: SystemCapability.Telephony.SmsMms
S
shawn_he 已提交
1799

S
shawn_he 已提交
1800
| Name| Type               | Mandatory| Description          |
S
shawn_he 已提交
1801 1802
| ---- | ------------------- | ---- | -------------- |
| pdu  | Array&lt;number&gt; | Yes  | SMS message delivery report.|
S
shawn_he 已提交
1803 1804


S
shawn_he 已提交
1805
## SendSmsResult
S
shawn_he 已提交
1806

S
shawn_he 已提交
1807
Enumerates SMS message sending results.
S
shawn_he 已提交
1808

S
shawn_he 已提交
1809 1810
**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1811
| Name                                | Value  | Description                                                  |
S
shawn_he 已提交
1812
| ------------------------------------ | ---- | ------------------------------------------------------ |
S
shawn_he 已提交
1813 1814
| SEND_SMS_SUCCESS                     | 0    | The SMS message is sent successfully.                                        |
| SEND_SMS_FAILURE_UNKNOWN             | 1    | Failed to send the SMS message due to an unknown reason.                              |
S
shawn_he 已提交
1815
| SEND_SMS_FAILURE_RADIO_OFF           | 2    | Failed to send the SMS message because the modem is shut down.                  |
S
shawn_he 已提交
1816
| 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.|
S
shawn_he 已提交
1817 1818 1819 1820 1821

## MmsInformation<sup>8+</sup>

Defines the MMS message information.

S
shawn_he 已提交
1822
**System API**: This is a system API.
S
shawn_he 已提交
1823 1824 1825

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1826 1827 1828 1829
|     Name   | Type                                                        | Mandatory|    Description   |
| ----------- | ------------------------------------------------------------ | ---- | ---------- |
| messageType | [MessageType](#messagetype8)                                 | Yes  | Message type.|
| mmsType     | [MmsSendReq](#mmssendreq8) \|[MmsSendConf](#mmssendconf8) \|[MmsNotificationInd](#mmsnotificationind8) \|[MmsRespInd](#mmsrespind8) \|[MmsRetrieveConf](#mmsretrieveconf8)\|[MmsAcknowledgeInd](#mmsacknowledgeind8)\|[MmsDeliveryInd](#mmsdeliveryind8)\|[MmsReadOrigInd](#mmsreadorigind8)\|[MmsReadRecInd](#mmsreadrecind8) | Yes  | PDU header type.|
S
shawn_he 已提交
1830 1831 1832 1833 1834 1835
| attachment  | Array<[MmsAttachment](#mmsattachment8)\>                     | No  | Attachment.     |

## MmsSendReq<sup>8+</sup>

Defines an MMS message sending request.

S
shawn_he 已提交
1836
**System API**: This is a system API.
S
shawn_he 已提交
1837 1838 1839

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1840
|       Name      | Type                                | Mandatory| Description        |
S
shawn_he 已提交
1841 1842 1843 1844 1845
| ---------------- | ------------------------------------ | ---- | ------------ |
| from             | [MmsAddress](#mmsaddress8)           | Yes  | MMS message source.    |
| transactionId    | string                               | Yes  | Transaction ID.      |
| contentType      | string                               | Yes  | Content type.    |
| version          | [MmsVersionType](#mmsversiontype8)   | Yes  | Version.        |
S
shawn_he 已提交
1846
| to               | Array<[MmsAddress](#mmsaddress8)\>   | No  | Destination address.      |
S
shawn_he 已提交
1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861
| date             | number                               | No  | Date.        |
| cc               | Array<[MmsAddress](#mmsaddress8)\>   | No  | Carbon copy.        |
| bcc              | Array<[MmsAddress](#mmsaddress8)\>   | No  | Blind carbon copy.      |
| subject          | string                               | No  | Subject.        |
| messageClass     | number                               | No  | Message class.      |
| expiry           | number                               | No  | Expiration.        |
| priority         | [MmsPriorityType](#mmsprioritytype8) | No  | Priority.        |
| senderVisibility | number                               | No  | Sender visibility.|
| deliveryReport   | number                               | No  | Delivery report.    |
| readReport       | number                               | No  | Read report.    |

## MmsSendConf<sup>8+</sup>

Defines the MMS message sending configuration.

S
shawn_he 已提交
1862
**System API**: This is a system API.
S
shawn_he 已提交
1863 1864 1865

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1866
|     Name     | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1867 1868 1869 1870 1871 1872 1873 1874 1875 1876
| ------------- | ---------------------------------- | ---- | -------- |
| responseState | number                             | Yes  | Response status.|
| transactionId | string                             | Yes  | Transaction ID.  |
| version       | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
| messageId     | string                             | No  | Message ID.  |

## MmsNotificationInd<sup>8+</sup>

Defines an MMS notification index.

S
shawn_he 已提交
1877
**System API**: This is a system API.
S
shawn_he 已提交
1878 1879 1880

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1881
|      Name      | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1882 1883 1884 1885 1886 1887 1888
| --------------- | ---------------------------------- | ---- | -------- |
| transactionId   | string                             | Yes  | Transaction ID.  |
| messageClass    | number                             | Yes  | Message class.  |
| messageSize     | number                             | Yes  | Message size.|
| expiry          | number                             | Yes  | Expiration.    |
| contentLocation | string                             | Yes  | Content location.|
| version         | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
S
shawn_he 已提交
1889
| from            | [MmsAddress](#mmsaddress8)         | No  | Source address.    |
S
shawn_he 已提交
1890 1891 1892 1893 1894 1895 1896 1897
| subject         | string                             | No  | Subject.    |
| deliveryReport  | number                             | No  | Status report.|
| contentClass    | number                             | No  | Content class.  |

## MmsAcknowledgeInd<sup>8+</sup>

Defines an MMS confirmation index.

S
shawn_he 已提交
1898
**System API**: This is a system API.
S
shawn_he 已提交
1899 1900 1901

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1902
|      Name    | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1903 1904 1905 1906 1907 1908 1909 1910 1911
| ------------- | ---------------------------------- | ---- | -------- |
| transactionId | string                             | Yes  | Transaction ID.  |
| version       | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
| reportAllowed | [ReportType](#reporttype8)         | No  | Report allowed.|

## MmsRetrieveConf<sup>8+</sup>

Defines the MMS message retrieval configuration.

S
shawn_he 已提交
1912
**System API**: This is a system API.
S
shawn_he 已提交
1913 1914 1915

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1916
|      Name     | Type                                | Mandatory| Description    |
S
shawn_he 已提交
1917 1918 1919 1920 1921
| -------------- | ------------------------------------ | ---- | -------- |
| transactionId  | string                               | Yes  | Transaction ID.  |
| messageId      | string                               | Yes  | Message ID.  |
| date           | number                               | Yes  | Date.    |
| contentType    | string                               | Yes  | Content type.|
S
shawn_he 已提交
1922 1923 1924
| to             | Array<[MmsAddress](#mmsaddress8)\>   | Yes  | Destination address.  |
| version        | [MmsVersionType](#mmsversiontype8)   | Yes  | Version.    |
| from           | [MmsAddress](#mmsaddress8)           | No  | Source address.    |
S
shawn_he 已提交
1925 1926
| cc             | Array<[MmsAddress](#mmsaddress8)\>   | No  | Carbon copy.    |
| subject        | string                               | No  | Subject.    |
S
shawn_he 已提交
1927
| priority       | [MmsPriorityType](#mmsprioritytype8) | No  | Priority.  |
S
shawn_he 已提交
1928 1929 1930 1931 1932 1933 1934 1935 1936
| deliveryReport | number                               | No  | Status report.|
| readReport     | number                               | No  | Read report.|
| retrieveStatus | number                               | No  | Retrieval status.|
| retrieveText   | string                               | No  | Retrieval text.|

## MmsReadOrigInd<sup>8+</sup>

Defines the original MMS message reading index.

S
shawn_he 已提交
1937
**System API**: This is a system API.
S
shawn_he 已提交
1938 1939 1940

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1941
|    Name   | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1942 1943 1944
| ---------- | ---------------------------------- | ---- | -------- |
| version    | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
| messageId  | string                             | Yes  | Message ID.  |
S
shawn_he 已提交
1945 1946
| to         | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.  |
| from       | [MmsAddress](#mmsaddress8)         | Yes  | Source address.    |
S
shawn_he 已提交
1947 1948 1949
| date       | number                             | Yes  | Date.    |
| readStatus | number                             | Yes  | Read status.|

S
shawn_he 已提交
1950 1951 1952 1953
## MmsReadRecInd<sup>8+</sup>

Defines the MMS message reading index.

S
shawn_he 已提交
1954
**System API**: This is a system API.
S
shawn_he 已提交
1955 1956 1957

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1958
|    Name   | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1959
| ---------- | ---------------------------------- | ---- | -------- |
S
shawn_he 已提交
1960
| version    | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
S
shawn_he 已提交
1961
| messageId  | string                             | Yes  | Message ID.  |
S
shawn_he 已提交
1962 1963 1964
| to         | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.  |
| from       | [MmsAddress](#mmsaddress8)         | Yes  | Source address.    |
| readStatus | number                             | Yes  | Read status.|
S
shawn_he 已提交
1965 1966
| date       | number                             | No  | Date.    |

S
shawn_he 已提交
1967 1968 1969 1970
## MmsAttachment<sup>8+</sup>

Defines the attachment of an MMS message.

S
shawn_he 已提交
1971
**System API**: This is a system API.
S
shawn_he 已提交
1972 1973 1974

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1975
|          Name          | Type                                | Mandatory| Description              |
S
shawn_he 已提交
1976 1977 1978 1979 1980 1981 1982 1983
| ----------------------- | ------------------------------------ | ---- | ------------------ |
| contentId               | string                               | Yes  | Content ID.            |
| contentLocation         | string                               | Yes  | Content location.          |
| contentDisposition      | [DispositionType](#dispositiontype8) | Yes  | Content disposition.          |
| contentTransferEncoding | string                               | Yes  | Encoding for content transfer.      |
| contentType             | string                               | Yes  | Content type.          |
| isSmil                  | boolean                              | Yes  | Whether the synchronized multimedia integration language is used.|
| path                    | string                               | No  | Path.              |
S
shawn_he 已提交
1984
| inBuff                  | Array<number\>                       | No  | Whether the message is in the buffer.          |
S
shawn_he 已提交
1985 1986 1987 1988 1989 1990 1991
| fileName                | string                               | No  | File name.            |
| charset                 | [MmsCharSets](#mmscharsets8)         | No  | Character set.            |

## MmsAddress<sup>8+</sup>

Defines an MMSC address.

S
shawn_he 已提交
1992
**System API**: This is a system API.
S
shawn_he 已提交
1993 1994 1995

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
1996
|   Name | Type                        | Mandatory| Description  |
S
shawn_he 已提交
1997
| ------- | ---------------------------- | ---- | ------ |
S
shawn_he 已提交
1998
| address | string                       | Yes  | Network address.  |
S
shawn_he 已提交
1999 2000 2001 2002
| charset | [MmsCharSets](#mmscharsets8) | Yes  | Character set.|

## MessageType<sup>8+</sup>

S
shawn_he 已提交
2003
Message type.
S
shawn_he 已提交
2004

S
shawn_he 已提交
2005
**System API**: This is a system API.
S
shawn_he 已提交
2006 2007 2008

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2009
|          Name            | Value  | Description                |
S
shawn_he 已提交
2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024
| ------------------------- | ---- | -------------------- |
| TYPE_MMS_SEND_REQ         | 128  | MMS message sending request.    |
| TYPE_MMS_SEND_CONF        | 129  | MMS message sending configuration.    |
| TYPE_MMS_NOTIFICATION_IND | 130  | MMS notification index.    |
| TYPE_MMS_RESP_IND         | 131  | MMS message response index.    |
| TYPE_MMS_RETRIEVE_CONF    | 132  | MMS message retrieval configuration.    |
| TYPE_MMS_ACKNOWLEDGE_IND  | 133  | MMS message acknowledgement index.    |
| TYPE_MMS_DELIVERY_IND     | 134  | MMS message delivery index.    |
| TYPE_MMS_READ_REC_IND     | 135  | MMS message reading and receiving index.|
| TYPE_MMS_READ_ORIG_IND    | 136  | Original MMS message reading index.|

## MmsPriorityType<sup>8+</sup>

Enumerates MMS message priorities.

S
shawn_he 已提交
2025
**System API**: This is a system API.
S
shawn_he 已提交
2026 2027 2028

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2029
|    Name   | Value  | Description          |
S
shawn_he 已提交
2030 2031 2032 2033 2034 2035 2036 2037 2038
| ---------- | ---- | -------------- |
| MMS_LOW    | 128  | Low priority.  |
| MMS_NORMAL | 129  | Normal priority.|
| MMS_HIGH   | 130  | High priority.  |

## MmsVersionType<sup>8+</sup>

Enumerates MMS versions.

S
shawn_he 已提交
2039
**System API**: This is a system API.
S
shawn_he 已提交
2040 2041 2042

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2043
|      Name      | Value  | Description       |
S
shawn_he 已提交
2044 2045 2046 2047 2048 2049 2050 2051 2052 2053
| --------------- | ---- | ----------- |
| MMS_VERSION_1_0 | 0x10 | MMS version 1_0.|
| MMS_VERSION_1_1 | 0x11 | MMS version 1_1.|
| MMS_VERSION_1_2 | 0x12 | MMS version 1_2.|
| MMS_VERSION_1_3 | 0x13 | MMS version 1_3.|

## MmsCharSets<sup>8+</sup>

Enumerates MMS character sets.

S
shawn_he 已提交
2054
**System API**: This is a system API.
S
shawn_he 已提交
2055 2056 2057

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2058
|      Name      | Value    | Description               |
S
shawn_he 已提交
2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078
| --------------- | ------ | ------------------- |
| BIG5            | 0X07EA | BIG5 format.           |
| ISO_10646_UCS_2 | 0X03E8 | ISO_10646_UCS_2 format.|
| ISO_8859_1      | 0X04   | ISO_8859_1 format.     |
| ISO_8859_2      | 0X05   | ISO_8859_2 format.     |
| ISO_8859_3      | 0X06   | ISO_8859_3 format.     |
| ISO_8859_4      | 0X07   | ISO_8859_4 format.     |
| ISO_8859_5      | 0X08   | ISO_8859_5 format.     |
| ISO_8859_6      | 0X09   | ISO_8859_6 format.     |
| ISO_8859_7      | 0X0A   | ISO_8859_7 format.     |
| ISO_8859_8      | 0X0B   | ISO_8859_8 format.     |
| ISO_8859_9      | 0X0C   | ISO_8859_9 format.     |
| SHIFT_JIS       | 0X11   | SHIFT_JIS format.      |
| US_ASCII        | 0X03   | US_ASCII format.       |
| UTF_8           | 0X6A   | UTF_8 format.          |

## DispositionType<sup>8+</sup>

Enumerates disposition types.

S
shawn_he 已提交
2079
**System API**: This is a system API.
S
shawn_he 已提交
2080 2081 2082

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2083
|    Name   | Value  | Description    |
S
shawn_he 已提交
2084 2085 2086 2087 2088 2089 2090 2091 2092
| ---------- | ---- | -------- |
| FROM_DATA  | 0    | Data source.|
| ATTACHMENT | 1    | Attachment.    |
| INLINE     | 2    | Inlining.    |

## ReportType<sup>8+</sup>

Enumerates report types.

S
shawn_he 已提交
2093
**System API**: This is a system API.
S
shawn_he 已提交
2094 2095 2096

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2097
|  Name  | Value  | Description|
S
shawn_he 已提交
2098 2099 2100 2101
| ------- | ---- | ---- |
| MMS_YES | 128  | YES  |
| MMS_NO  | 129  | NO   |

S
shawn_he 已提交
2102
## CBConfigOptions<sup>7+</sup>
S
shawn_he 已提交
2103 2104 2105

Defines the cell broadcast configuration options.

S
shawn_he 已提交
2106
**System API**: This is a system API.
S
shawn_he 已提交
2107 2108 2109

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2110
|      Name     | Type                | Mandatory| Description        |
S
shawn_he 已提交
2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121
| -------------- | -------------------- | ---- | ------------ |
| slotId         | number               | Yes  | Card slot ID.      |
| enable         | boolean              | Yes  | Whether to enable cell broadcast.        |
| startMessageId | number               | Yes  | Start message ID.  |
| endMessageId   | number               | Yes  | End message ID.  |
| ranType        | [RanType](#rantype7) | Yes  | RAN type.|

## SimMessageStatus<sup>7+</sup>

Defines the SIM message status.

S
shawn_he 已提交
2122
**System API**: This is a system API.
S
shawn_he 已提交
2123 2124 2125

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2126
|           Name           | Value  | Description                       |
S
shawn_he 已提交
2127 2128 2129 2130 2131 2132 2133 2134 2135
| ------------------------- | ---- | --------------------------- |
| SIM_MESSAGE_STATUS_FREE   | 0    | Free state.      |
| SIM_MESSAGE_STATUS_READ   | 1    | Read state.               |
| SIM_MESSAGE_STATUS_UNREAD | 3    | Unread state.               |
| SIM_MESSAGE_STATUS_SENT   | 5    | Storage of sent messages (applicable only to SMS).|
| SIM_MESSAGE_STATUS_UNSENT | 7    | Storage of unsent messages (applicable only to SMS).|

## RanType<sup>7+</sup>

S
shawn_he 已提交
2136
RAN type.
S
shawn_he 已提交
2137

S
shawn_he 已提交
2138
**System API**: This is a system API.
S
shawn_he 已提交
2139 2140 2141

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2142
|   Name   | Value  | Description|
S
shawn_he 已提交
2143 2144 2145 2146 2147 2148 2149 2150
| --------- | ---- | ---- |
| TYPE_GSM  | 1    | GSM  |
| TYPE_CDMA | 2    | CMDA |

## SmsEncodingScheme<sup>8+</sup>

Enumerates SMS encoding schemes.

S
shawn_he 已提交
2151
**System API**: This is a system API.
S
shawn_he 已提交
2152 2153 2154

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2155
|         Name        | Value  | Description        |
S
shawn_he 已提交
2156 2157 2158 2159 2160 2161 2162 2163 2164 2165
| -------------------- | ---- | ------------ |
| SMS_ENCODING_UNKNOWN | 0    | Unknown code.|
| SMS_ENCODING_7BIT    | 1    | 7-digit code. |
| SMS_ENCODING_8BIT    | 2    | 8-digit code. |
| SMS_ENCODING_16BIT   | 3    | 16-digit code.|

## SimMessageOptions<sup>7+</sup>

Defines the SIM message options.

S
shawn_he 已提交
2166
**System API**: This is a system API.
S
shawn_he 已提交
2167 2168 2169

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2170
|  Name | Type                                  | Mandatory| Description          |
S
shawn_he 已提交
2171 2172 2173 2174
| ------ | -------------------------------------- | ---- | -------------- |
| slotId | number                                 | Yes  | Card slot ID.        |
| smsc   | string                                 | Yes  | Short message service center.|
| pdu    | string                                 | Yes  | Protocol data unit.  |
S
shawn_he 已提交
2175
| status | [SimMessageStatus](#simmessagestatus7) | Yes  | Status.          |
S
shawn_he 已提交
2176 2177 2178 2179 2180

## UpdateSimMessageOptions<sup>7+</sup>

Defines the updating SIM message options.

S
shawn_he 已提交
2181
**System API**: This is a system API.
S
shawn_he 已提交
2182 2183 2184

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2185
|   Name   | Type                                  | Mandatory| Description          |
S
shawn_he 已提交
2186 2187 2188 2189 2190 2191 2192
| --------- | -------------------------------------- | ---- | -------------- |
| slotId    | number                                 | Yes  | Card slot ID.        |
| msgIndex  | number                                 | Yes  | Message index.      |
| newStatus | [SimMessageStatus](#simmessagestatus7) | Yes  | New status.        |
| pdu       | string                                 | Yes  | Protocol data unit.  |
| smsc      | string                                 | Yes  | Short message service center.|

S
shawn_he 已提交
2193
## SimShortMessage<sup>7+</sup>
S
shawn_he 已提交
2194 2195 2196

Defines a SIM message.

S
shawn_he 已提交
2197
**System API**: This is a system API.
S
shawn_he 已提交
2198 2199 2200

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2201
|       Name      | Type                                  | Mandatory| Description         |
S
shawn_he 已提交
2202 2203 2204 2205 2206 2207 2208 2209 2210
| ---------------- | -------------------------------------- | ---- | ------------- |
| shortMessage     | [ShortMessage](#shortmessage)          | Yes  | SMS message.       |
| simMessageStatus | [SimMessageStatus](#simmessagestatus7) | Yes  | SIM message status.|
| indexOnSim       | number                                 | Yes  | SIM card index.    |

## MmsDeliveryInd<sup>8+</sup>

Defines an MMS message delivery index.

S
shawn_he 已提交
2211
**System API**: This is a system API.
S
shawn_he 已提交
2212 2213 2214

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2215
|    Name  | Type                              | Mandatory| Description  |
S
shawn_he 已提交
2216 2217 2218
| --------- | ---------------------------------- | ---- | ------ |
| messageId | string                             | Yes  | Message ID.|
| date      | number                             | Yes  | Date.  |
S
shawn_he 已提交
2219
| to        | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.|
S
shawn_he 已提交
2220
| status    | number                             | Yes  | Status.  |
S
shawn_he 已提交
2221 2222 2223 2224 2225 2226
| version   | [MmsVersionType](#mmsversiontype8) | Yes  | Version.  |

## MmsRespInd<sup>8+</sup>

Defines an MMS response index.

S
shawn_he 已提交
2227
**System API**: This is a system API.
S
shawn_he 已提交
2228 2229 2230

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2231
|     Name     | Type                              | Mandatory| Description    |
S
shawn_he 已提交
2232 2233
| ------------- | ---------------------------------- | ---- | -------- |
| transactionId | string                             | Yes  | Event ID.  |
S
shawn_he 已提交
2234
| status        | number                             | Yes  | Status.    |
S
shawn_he 已提交
2235 2236 2237 2238 2239 2240 2241
| version       | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
| reportAllowed | [ReportType](#reporttype8)         | No  | Report allowed.|

## SmsSegmentsInfo<sup>8+</sup>

Defines the SMS message segment information.

S
shawn_he 已提交
2242
**System API**: This is a system API.
S
shawn_he 已提交
2243 2244 2245

**System capability**: SystemCapability.Telephony.SmsMms

S
shawn_he 已提交
2246
|        Name         | Type                                    | Mandatory| Description        |
S
shawn_he 已提交
2247 2248 2249 2250 2251
| -------------------- | ---------------------------------------- | ---- | ------------ |
| splitCount           | number                                   | Yes  | Split count.    |
| encodeCount          | number                                   | Yes  | Encoding count.    |
| encodeCountRemaining | number                                   | Yes  | Remaining encoding count.|
| scheme               | [SmsEncodingScheme](#smsencodingscheme8) | Yes  | Encoding scheme.|