js-apis-sms.md 82.8 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 102 103

## sms.sendMessage

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

Sends an SMS message.

S
shawn_he 已提交
108
**Required permissions**: ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
109 110

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

S
shawn_he 已提交
112
**Parameters**
S
shawn_he 已提交
113

S
shawn_he 已提交
114
| Name | Type                                     | Mandatory| Description                                                        |
S
shawn_he 已提交
115
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
116
| options | [SendMessageOptions](#sendmessageoptions) | Yes  | Options (including the callback) for sending an SMS message.|
S
shawn_he 已提交
117

S
shawn_he 已提交
118 119 120 121 122 123 124 125 126 127 128 129 130
**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 已提交
131
**Example**
S
shawn_he 已提交
132

S
shawn_he 已提交
133
```js
S
shawn_he 已提交
134 135 136 137 138 139 140 141 142 143 144 145 146 147
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);
```
S
shawn_he 已提交
148 149


S
shawn_he 已提交
150
## sms.getDefaultSmsSlotId<sup>7+</sup>
S
shawn_he 已提交
151

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

S
shawn_he 已提交
154
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 已提交
155

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

S
shawn_he 已提交
158
**Parameters**
S
shawn_he 已提交
159

S
shawn_he 已提交
160
| Name  | Type                       | Mandatory| Description                                    |
S
shawn_he 已提交
161
| -------- | --------------------------- | ---- | ---------------------------------------- |
S
shawn_he 已提交
162
| 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 已提交
163

S
shawn_he 已提交
164
**Example**
S
shawn_he 已提交
165

S
shawn_he 已提交
166
```js
S
shawn_he 已提交
167 168 169 170
sms.getDefaultSmsSlotId((err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
171 172


S
shawn_he 已提交
173
## sms.getDefaultSmsSlotId<sup>7+</sup>
S
shawn_he 已提交
174

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

S
shawn_he 已提交
177
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 已提交
178

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

S
shawn_he 已提交
181
**Return value**
S
shawn_he 已提交
182

S
shawn_he 已提交
183
| Type           | Description                                                        |
S
shawn_he 已提交
184
| --------------- | ------------------------------------------------------------ |
S
shawn_he 已提交
185
| Promise&lt;number&gt; | Promise used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
186

S
shawn_he 已提交
187
**Example**
S
shawn_he 已提交
188

S
shawn_he 已提交
189
```js
S
shawn_he 已提交
190
let promise = sms.getDefaultSmsSlotId();
S
shawn_he 已提交
191 192 193
promise.then(data => {
    console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
194
    console.error(`getDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
195 196
});
```
S
shawn_he 已提交
197

S
shawn_he 已提交
198 199
## sms.setDefaultSmsSlotId<sup>7+</sup>

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

S
shawn_he 已提交
202
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 已提交
203

S
shawn_he 已提交
204
**System API**: This is a system API.
S
shawn_he 已提交
205

S
shawn_he 已提交
206
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE
S
shawn_he 已提交
207 208 209 210 211 212 213

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

**Parameters**

| Name  | Type                     | Mandatory| Description                                                        |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
214
| 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 已提交
215 216
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                                  |

S
shawn_he 已提交
217 218
**Error codes**

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

S
shawn_he 已提交
221 222 223
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
224
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
225 226 227 228 229 230 231
| 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 已提交
232 233 234
**Example**

```js
S
shawn_he 已提交
235 236
sms.setDefaultSmsSlotId(0, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}.`);
S
shawn_he 已提交
237 238 239 240 241 242 243 244
});
```


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

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

S
shawn_he 已提交
245
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 已提交
246

S
shawn_he 已提交
247
**System API**: This is a system API.
S
shawn_he 已提交
248

S
shawn_he 已提交
249
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE
S
shawn_he 已提交
250 251 252 253 254 255 256

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

**Parameters**

| Name| Type  | Mandatory| Description                                                        |
| ------ | ------ | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
257
| 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 已提交
258 259 260

**Return value**

S
shawn_he 已提交
261 262 263 264 265 266
| Type           | Description                           |
| --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.|

**Error codes**

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

S
shawn_he 已提交
269 270 271
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
272
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
273 274 275 276 277 278
| 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 已提交
279 280 281 282 283

**Example**

```js
let promise = sms.setDefaultSmsSlotId(0);
S
shawn_he 已提交
284 285 286
promise.then(() => {
    console.log(`setDefaultSmsSlotId success.`);
}).catch((err) => {
S
shawn_he 已提交
287
    console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
288 289
});
```
S
shawn_he 已提交
290

S
shawn_he 已提交
291
## sms.setSmscAddr<sup>7+</sup>
S
shawn_he 已提交
292

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

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

S
shawn_he 已提交
297
**System API**: This is a system API.
S
shawn_he 已提交
298

S
shawn_he 已提交
299
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
300 301

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

S
shawn_he 已提交
303
**Parameters**
S
shawn_he 已提交
304

S
shawn_he 已提交
305
| Name  | Type                     | Mandatory| Description                                     |
S
shawn_he 已提交
306
| -------- | ------------------------- | ---- | ----------------------------------------- |
S
shawn_he 已提交
307
| slotId   | number                    | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
308
| smscAddr | string                    | Yes  | SMSC address.                       |
S
shawn_he 已提交
309
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                               |
S
shawn_he 已提交
310

S
shawn_he 已提交
311 312
**Error codes**

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

S
shawn_he 已提交
315 316 317
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
318
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
319 320 321 322 323 324
| 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 已提交
325
**Example**
S
shawn_he 已提交
326

S
shawn_he 已提交
327
```js
S
shawn_he 已提交
328 329
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
S
shawn_he 已提交
330 331
sms.setSmscAddr(slotId, smscAddr, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
332 333
});
```
S
shawn_he 已提交
334 335


S
shawn_he 已提交
336
## sms.setSmscAddr<sup>7+</sup>
S
shawn_he 已提交
337

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

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

S
shawn_he 已提交
342
**System API**: This is a system API.
S
shawn_he 已提交
343

S
shawn_he 已提交
344
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
345 346

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

S
shawn_he 已提交
348
**Parameters**
S
shawn_he 已提交
349

S
shawn_he 已提交
350
| Name  | Type  | Mandatory| Description                                     |
S
shawn_he 已提交
351
| -------- | ------ | ---- | ----------------------------------------- |
S
shawn_he 已提交
352
| slotId   | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
353
| smscAddr | string | Yes  | SMSC address.                       |
S
shawn_he 已提交
354

S
shawn_he 已提交
355
**Return value**
S
shawn_he 已提交
356

S
shawn_he 已提交
357
| Type               | Description                           |
S
shawn_he 已提交
358 359
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
S
shawn_he 已提交
360

S
shawn_he 已提交
361 362
**Error codes**

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

S
shawn_he 已提交
365 366 367
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
368
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
369 370 371 372 373 374
| 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 已提交
375
**Example**
S
shawn_he 已提交
376

S
shawn_he 已提交
377
```js
S
shawn_he 已提交
378 379 380
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
let promise = sms.setSmscAddr(slotId, smscAddr);
S
shawn_he 已提交
381 382 383
promise.then(() => {
    console.log(`setSmscAddr success.`);
}).catch((err) => {
S
shawn_he 已提交
384
    console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
385 386
});
```
S
shawn_he 已提交
387 388


S
shawn_he 已提交
389
## sms.getSmscAddr<sup>7+</sup>
S
shawn_he 已提交
390

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

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

S
shawn_he 已提交
395
**System API**: This is a system API.
S
shawn_he 已提交
396

S
shawn_he 已提交
397
**Required permissions**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
398 399

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

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

S
shawn_he 已提交
403
| Name  | Type                       | Mandatory| Description                                     |
S
shawn_he 已提交
404
| -------- | --------------------------- | ---- | ----------------------------------------- |
S
shawn_he 已提交
405 406
| 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 已提交
407

S
shawn_he 已提交
408 409
**Error codes**

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

S
shawn_he 已提交
412 413 414
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
415
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
416 417 418 419 420 421
| 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 已提交
422
**Example**
S
shawn_he 已提交
423

S
shawn_he 已提交
424
```js
S
shawn_he 已提交
425 426 427 428 429
let slotId = 0;
sms.getSmscAddr(slotId, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
430 431


S
shawn_he 已提交
432
## sms.getSmscAddr<sup>7+</sup>
S
shawn_he 已提交
433

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

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

S
shawn_he 已提交
438
**System API**: This is a system API.
S
shawn_he 已提交
439

S
shawn_he 已提交
440
**Required permissions**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
441 442

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

S
shawn_he 已提交
444
**Parameters**
S
shawn_he 已提交
445

S
shawn_he 已提交
446
| Name| Type  | Mandatory| Description                                     |
S
shawn_he 已提交
447
| ------ | ------ | ---- | ----------------------------------------- |
S
shawn_he 已提交
448
| slotId | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
449

S
shawn_he 已提交
450
**Return value**
S
shawn_he 已提交
451

S
shawn_he 已提交
452
| Type                 | Description                                         |
S
shawn_he 已提交
453 454
| --------------------- | --------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.|
S
shawn_he 已提交
455

S
shawn_he 已提交
456 457
**Error codes**

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

S
shawn_he 已提交
460 461 462
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
463
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
464 465 466 467 468 469
| 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 已提交
470
**Example**
S
shawn_he 已提交
471

S
shawn_he 已提交
472
```js
S
shawn_he 已提交
473 474 475 476 477
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 已提交
478
    console.error(`getSmscAddr failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
479 480
});
```
S
shawn_he 已提交
481

S
shawn_he 已提交
482
## sms.hasSmsCapability<sup>7+</sup>
S
shawn_he 已提交
483

S
shawn_he 已提交
484
hasSmsCapability\(\): boolean
S
shawn_he 已提交
485

S
shawn_he 已提交
486
Checks whether the current device can send and receive SMS messages. This API works in synchronous mode.
S
shawn_he 已提交
487 488 489

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

S
shawn_he 已提交
490
**Return value**
S
shawn_he 已提交
491 492 493 494 495

| 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 已提交
496
```js
S
shawn_he 已提交
497 498 499
let result = sms.hasSmsCapability(); 
console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
```
S
shawn_he 已提交
500

S
shawn_he 已提交
501 502
## sms.splitMessage<sup>8+</sup>

S
shawn_he 已提交
503
splitMessage\(content: string, callback: AsyncCallback\<Array\<string\>\>\): void
S
shawn_he 已提交
504 505 506

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

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

S
shawn_he 已提交
509
**Required permissions**: ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
510 511 512 513 514 515 516 517 518 519

**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 已提交
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 535 536
**Example**

```js
S
shawn_he 已提交
537
let content = "long message";
S
shawn_he 已提交
538 539 540 541 542 543 544 545
sms.splitMessage(content, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


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

S
shawn_he 已提交
546
splitMessage\(content: string\): Promise\<Array\<string\>\>
S
shawn_he 已提交
547 548 549

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

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

S
shawn_he 已提交
552
**Required permissions**: ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567

**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 已提交
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 583 584
**Example**

```js
S
shawn_he 已提交
585
let content = "long message";
S
shawn_he 已提交
586 587 588 589
let promise = sms.splitMessage(content);
promise.then(data => {
    console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
590
    console.error(`splitMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
591 592 593 594 595
});
```

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

S
shawn_he 已提交
596
addSimMessage\(options: SimMessageOptions, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
597 598 599

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

S
shawn_he 已提交
600
**System API**: This is a system API.
S
shawn_he 已提交
601

S
shawn_he 已提交
602
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
603 604 605 606 607 608 609 610 611 612

**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 已提交
613 614
**Error codes**

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

S
shawn_he 已提交
617 618 619
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
620
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
621 622 623 624 625 626
| 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 已提交
627 628 629 630
**Example**

```js
let simMessageOptions = {
S
shawn_he 已提交
631 632 633 634
    slotId: 0,
    smsc: "test",
    pdu: "xxxxxx",
    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
S
shawn_he 已提交
635
};
S
shawn_he 已提交
636 637
sms.addSimMessage(simMessageOptions, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
638 639 640 641 642 643
});
```


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

S
shawn_he 已提交
644
addSimMessage\(options: SimMessageOptions\): Promise\<void\>
S
shawn_he 已提交
645 646 647

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

S
shawn_he 已提交
648
**System API**: This is a system API.
S
shawn_he 已提交
649

S
shawn_he 已提交
650
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665

**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 已提交
666 667
**Error codes**

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

S
shawn_he 已提交
670 671 672
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
673
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
674 675 676 677 678 679
| 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 已提交
680 681 682 683
**Example**

```js
let simMessageOptions = {
S
shawn_he 已提交
684 685 686 687
    slotId: 0,
    smsc: "test",
    pdu: "xxxxxx",
    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
S
shawn_he 已提交
688 689
};
let promise = sms.addSimMessage(simMessageOptions);
S
shawn_he 已提交
690 691 692
promise.then(() => {
    console.log(`addSimMessage success.`);
}).catch((err) => {
S
shawn_he 已提交
693
    console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
694 695 696 697 698
});
```

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

S
shawn_he 已提交
699
delSimMessage\(slotId: number, msgIndex: number, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
700 701 702

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

S
shawn_he 已提交
703
**System API**: This is a system API.
S
shawn_he 已提交
704

S
shawn_he 已提交
705
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
706 707 708 709 710 711 712 713 714 715 716

**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 已提交
717 718
**Error codes**

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

S
shawn_he 已提交
721 722 723
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
724
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
725 726 727 728 729 730
| 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 已提交
731 732 733 734 735
**Example**

```js
let slotId = 0;
let msgIndex = 1;
S
shawn_he 已提交
736 737
sms.delSimMessage(slotId, msgIndex, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
738 739 740 741 742 743
});
```


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

S
shawn_he 已提交
744
delSimMessage\(slotId: number, msgIndex: number\): Promise\<void\>
S
shawn_he 已提交
745 746 747

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

S
shawn_he 已提交
748
**System API**: This is a system API.
S
shawn_he 已提交
749

S
shawn_he 已提交
750
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766

**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 已提交
767 768
**Error codes**

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

S
shawn_he 已提交
771 772 773
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
774
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
775 776 777 778 779 780
| 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 已提交
781 782 783 784 785 786
**Example**

```js
let slotId = 0;
let msgIndex = 1;
let promise = sms.delSimMessage(slotId, msgIndex);
S
shawn_he 已提交
787 788 789
promise.then(() => {
    console.log(`delSimMessage success.`);
}).catch((err) => {
S
shawn_he 已提交
790
    console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
791 792 793 794 795
});
```

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

S
shawn_he 已提交
796
updateSimMessage\(options: UpdateSimMessageOptions, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
797 798 799

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

S
shawn_he 已提交
800
**System API**: This is a system API.
S
shawn_he 已提交
801

S
shawn_he 已提交
802
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
803 804 805 806 807 808 809 810 811 812

**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 已提交
813 814
**Error codes**

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

S
shawn_he 已提交
817 818 819
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
820
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
821 822 823 824 825 826
| 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 已提交
827 828 829 830
**Example**

```js
let updateSimMessageOptions = {
S
shawn_he 已提交
831 832 833
    slotId: 0,
    msgIndex: 1,
    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
S
shawn_he 已提交
834 835
    pdu: "xxxxxxx",
    smsc: "test"
S
shawn_he 已提交
836
};
S
shawn_he 已提交
837 838
sms.updateSimMessage(updateSimMessageOptions, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
839 840 841 842 843 844
});
```


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

S
shawn_he 已提交
845
updateSimMessage\(options: UpdateSimMessageOptions\): Promise\<void\>
S
shawn_he 已提交
846 847 848

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

S
shawn_he 已提交
849
**System API**: This is a system API.
S
shawn_he 已提交
850

S
shawn_he 已提交
851
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866

**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 已提交
867 868
**Error codes**

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

S
shawn_he 已提交
871 872 873
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
874
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
875 876 877 878 879 880
| 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 已提交
881 882 883 884
**Example**

```js
let updateSimMessageOptions = {
S
shawn_he 已提交
885 886 887
    slotId: 0,
    msgIndex: 1,
    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
S
shawn_he 已提交
888 889
    pdu: "xxxxxxx",
    smsc: "test"
S
shawn_he 已提交
890 891
};
let promise = sms.updateSimMessage(updateSimMessageOptions);
S
shawn_he 已提交
892 893 894
promise.then(() => {
    console.log(`updateSimMessage success.`);
}).catch((err) => {
S
shawn_he 已提交
895
    console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
896 897 898 899 900
});
```

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

S
shawn_he 已提交
901
getAllSimMessages\(slotId: number, callback: AsyncCallback\<Array\<SimShortMessage\>\>\): void
S
shawn_he 已提交
902 903 904

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

S
shawn_he 已提交
905
**System API**: This is a system API.
S
shawn_he 已提交
906

S
shawn_he 已提交
907
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
908 909 910 911 912 913 914 915

**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 已提交
916
| callback | AsyncCallback<Array<[SimShortMessage](#simshortmessage7)\>> | Yes  | Callback used to return the result.                               |
S
shawn_he 已提交
917

S
shawn_he 已提交
918 919
**Error codes**

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

S
shawn_he 已提交
922 923 924
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
925
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
926 927 928 929 930 931
| 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 已提交
932 933 934 935 936 937 938 939 940 941 942 943
**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 已提交
944
getAllSimMessages\(slotId: number\): Promise\<Array\<SimShortMessage\>\>
S
shawn_he 已提交
945 946 947

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

S
shawn_he 已提交
948
**System API**: This is a system API.
S
shawn_he 已提交
949

S
shawn_he 已提交
950
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
951 952 953 954 955 956 957 958 959 960 961 962 963

**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 已提交
964
| PromiseArray<[SimShortMessage](#simshortmessage7)\>&gt; | Promise used to return the result.|
S
shawn_he 已提交
965

S
shawn_he 已提交
966 967
**Error codes**

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

S
shawn_he 已提交
970 971 972
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
973
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
974 975 976 977 978 979
| 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 已提交
980 981 982 983 984 985 986 987
**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 已提交
988
    console.error(`getAllSimMessages failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
989 990 991 992 993
});
```

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

S
shawn_he 已提交
994
setCBConfig\(options: CBConfigOptions, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
995 996 997

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

S
shawn_he 已提交
998
**System API**: This is a system API.
S
shawn_he 已提交
999

S
shawn_he 已提交
1000
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
1001 1002 1003 1004 1005 1006 1007

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

**Parameters**

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

S
shawn_he 已提交
1011 1012
**Error codes**

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

S
shawn_he 已提交
1015 1016 1017
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1018
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1019 1020 1021 1022 1023 1024
| 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 已提交
1025 1026 1027 1028
**Example**

```js
let cbConfigOptions = {
S
shawn_he 已提交
1029 1030 1031 1032 1033
    slotId: 0,
    enable: true,
    startMessageId: 100,
    endMessageId: 200,
    ranType: sms.RanType.TYPE_GSM
S
shawn_he 已提交
1034
};
S
shawn_he 已提交
1035 1036
sms.setCBConfig(cbConfigOptions, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1037 1038 1039 1040 1041 1042
});
```


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

S
shawn_he 已提交
1043
setCBConfig\(options: CBConfigOptions\): Promise\<void\>
S
shawn_he 已提交
1044 1045 1046

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

S
shawn_he 已提交
1047
**System API**: This is a system API.
S
shawn_he 已提交
1048

S
shawn_he 已提交
1049
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
1050 1051 1052 1053 1054 1055 1056

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

**Parameters**

| Name | Type                                | Mandatory| Description        |
| ------- | ------------------------------------ | ---- | ------------ |
S
shawn_he 已提交
1057
| options | [CBConfigOptions](#cbconfigoptions7) | Yes  | Cell broadcast configuration options.|
S
shawn_he 已提交
1058 1059 1060 1061 1062 1063 1064

**Return value**

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

S
shawn_he 已提交
1065 1066
**Error codes**

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

S
shawn_he 已提交
1069 1070 1071
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1072
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1073 1074 1075 1076 1077 1078
| 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 已提交
1079 1080 1081 1082
**Example**

```js
let cbConfigOptions = {
S
shawn_he 已提交
1083 1084 1085 1086 1087
    slotId: 0,
    enable: true,
    startMessageId: 100,
    endMessageId: 200,
    ranType: sms.RanType.TYPE_GSM
S
shawn_he 已提交
1088 1089
};
let promise = sms.setCBConfig(cbConfigOptions);
S
shawn_he 已提交
1090 1091 1092
promise.then(() => {
    console.log(`setCBConfig success.`);
}).catch((err) => {
S
shawn_he 已提交
1093
    console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1094 1095 1096 1097 1098
});
```

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

S
shawn_he 已提交
1099
getSmsSegmentsInfo\(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback\<SmsSegmentsInfo\>\): void
S
shawn_he 已提交
1100 1101 1102

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

S
shawn_he 已提交
1103
**System API**: This is a system API.
S
shawn_he 已提交
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113

**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 已提交
1114 1115 1116 1117
| callback  | AsyncCallback&lt;[SmsSegmentsInfo](#smssegmentsinfo8)&gt; | Yes  | Callback used to return the result.                                 |

**Error codes**

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

S
shawn_he 已提交
1120 1121
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1122
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1123 1124 1125 1126 1127
| 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 已提交
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140

**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 已提交
1141
getSmsSegmentsInfo\(slotId: number, message: string, force7bit: boolean\): Promise\<SmsSegmentsInfo\>
S
shawn_he 已提交
1142 1143 1144

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

S
shawn_he 已提交
1145
**System API**: This is a system API.
S
shawn_he 已提交
1146 1147 1148 1149 1150 1151 1152 1153

**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 已提交
1154
| message   | string  | Yes  | SMS message.                                     |
S
shawn_he 已提交
1155 1156 1157 1158 1159 1160
| force7bit | boolean | Yes  | Whether to use 7-bit coding.                         |

**Return value**

| Type                                                   | Description                         |
| ------------------------------------------------------- | ----------------------------- |
S
shawn_he 已提交
1161 1162 1163 1164
| Promise&lt;[SmsSegmentsInfo](#smssegmentsinfo8)&gt; | Promise used to return the result.|

**Error codes**

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

S
shawn_he 已提交
1167 1168
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1169
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1170 1171 1172 1173 1174
| 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 已提交
1175 1176 1177 1178 1179 1180

**Example**

```js
let slotId = 0;
let promise = sms.getSmsSegmentsInfo(slotId, "message", false);
S
shawn_he 已提交
1181
promise.then(data => {
S
shawn_he 已提交
1182 1183
    console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1184
    console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1185 1186 1187 1188 1189
});
```

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

S
shawn_he 已提交
1190
isImsSmsSupported\(slotId: number, callback: AsyncCallback\<boolean\>\): void
S
shawn_he 已提交
1191 1192 1193

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

S
shawn_he 已提交
1194
**System API**: This is a system API.
S
shawn_he 已提交
1195 1196 1197 1198 1199 1200 1201

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

**Parameters**

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

S
shawn_he 已提交
1205 1206
**Error codes**

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

S
shawn_he 已提交
1209 1210
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1211
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1212 1213 1214 1215 1216 1217
| 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 已提交
1218 1219 1220
**Example**

```js
S
shawn_he 已提交
1221 1222
let slotId = 0;
sms.isImsSmsSupported(slotId, (err, data) => {
S
shawn_he 已提交
1223
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
S
shawn_he 已提交
1224 1225 1226 1227 1228 1229
});
```


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

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

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

S
shawn_he 已提交
1234
**System API**: This is a system API.
S
shawn_he 已提交
1235 1236 1237

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

S
shawn_he 已提交
1238 1239 1240 1241 1242 1243
**Parameters**

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

S
shawn_he 已提交
1244 1245 1246 1247 1248 1249
**Return value**

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

S
shawn_he 已提交
1250 1251
**Error codes**

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

S
shawn_he 已提交
1254 1255
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1256
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1257 1258 1259 1260 1261 1262
| 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 已提交
1263 1264 1265
**Example**

```js
S
shawn_he 已提交
1266 1267
let slotId = 0;
let promise = sms.isImsSmsSupported(slotId);
S
shawn_he 已提交
1268 1269 1270
promise.then(data => {
    console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1271
    console.error(`isImsSmsSupported failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1272 1273 1274 1275 1276
});
```

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

S
shawn_he 已提交
1277
getImsShortMessageFormat\(callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
1278 1279 1280

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

S
shawn_he 已提交
1281
**System API**: This is a system API.
S
shawn_he 已提交
1282 1283 1284 1285 1286 1287 1288 1289 1290

**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 已提交
1291 1292
**Error codes**

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

S
shawn_he 已提交
1295 1296
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1297
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1298 1299 1300 1301 1302 1303
| 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 已提交
1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314
**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 已提交
1315
getImsShortMessageFormat\(\): Promise\<string\>
S
shawn_he 已提交
1316 1317 1318

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

S
shawn_he 已提交
1319
**System API**: This is a system API.
S
shawn_he 已提交
1320 1321 1322 1323 1324 1325 1326 1327 1328

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

**Return value**

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

S
shawn_he 已提交
1329 1330
**Error codes**

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

S
shawn_he 已提交
1333 1334
| ID|                  Error Message                   |
| -------- | -------------------------------------------- |
S
shawn_he 已提交
1335
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1336 1337 1338 1339
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1340 1341 1342 1343 1344 1345 1346
**Example**

```js
let promise = sms.getImsShortMessageFormat();
promise.then(data => {
    console.log(`getImsShortMessageFormat success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1347
    console.error(`getImsShortMessageFormat failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1348 1349 1350 1351 1352
});
```

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

S
shawn_he 已提交
1353
decodeMms\(mmsFilePathName: string | Array\<number\>, callback: AsyncCallback\<MmsInformation\>\): void
S
shawn_he 已提交
1354 1355 1356

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

S
shawn_he 已提交
1357
**System API**: This is a system API.
S
shawn_he 已提交
1358 1359 1360 1361 1362 1363 1364 1365 1366 1367

**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 已提交
1368 1369
**Error codes**

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

S
shawn_he 已提交
1372 1373 1374 1375 1376 1377 1378 1379
| 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 已提交
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391
**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 已提交
1392
decodeMms\(mmsFilePathName: string | Array\<number\>\): Promise\<MmsInformation\>
S
shawn_he 已提交
1393 1394 1395

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

S
shawn_he 已提交
1396
**System API**: This is a system API.
S
shawn_he 已提交
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411

**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 已提交
1412 1413
**Error codes**

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

S
shawn_he 已提交
1416 1417 1418 1419 1420 1421 1422 1423
| 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 已提交
1424 1425 1426 1427
**Example**

```js
let mmsFilePathName = "filename";
S
shawn_he 已提交
1428
let promise = sms.decodeMms(mmsFilePathName);
S
shawn_he 已提交
1429 1430 1431
promise.then(data => {
    console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1432
    console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1433 1434 1435 1436 1437
});
```

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

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

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

S
shawn_he 已提交
1442
**System API**: This is a system API.
S
shawn_he 已提交
1443 1444 1445 1446 1447 1448 1449 1450 1451 1452

**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 已提交
1453 1454
**Error codes**

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

S
shawn_he 已提交
1457 1458 1459 1460 1461 1462 1463 1464
| 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 已提交
1465 1466 1467 1468
**Example**

```js
let mmsAcknowledgeInd = {
S
shawn_he 已提交
1469 1470 1471
    transactionId: "100",
    version: sms.MmsVersionType.MMS_VERSION_1_0,
    reportAllowed: sms.ReportType.MMS_YES
S
shawn_he 已提交
1472 1473
};
let mmsInformation = {
S
shawn_he 已提交
1474 1475
    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
    mmsType: mmsAcknowledgeInd
S
shawn_he 已提交
1476 1477 1478 1479 1480 1481 1482 1483 1484
};
sms.encodeMms(mmsInformation, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


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

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

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

S
shawn_he 已提交
1489
**System API**: This is a system API.
S
shawn_he 已提交
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504

**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 已提交
1505 1506
**Error codes**

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

S
shawn_he 已提交
1509 1510 1511 1512 1513 1514 1515 1516
| 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 已提交
1517 1518 1519 1520
**Example**

```js
let mmsAcknowledgeInd = {
S
shawn_he 已提交
1521 1522
    transactionId: "100",
    version: sms.MmsVersionType.MMS_VERSION_1_0,
S
shawn_he 已提交
1523
    reportAllowed: sms.ReportType.MMS_YES
S
shawn_he 已提交
1524 1525
};
let mmsInformation = {
S
shawn_he 已提交
1526
    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
S
shawn_he 已提交
1527
    mmsType: mmsAcknowledgeInd
S
shawn_he 已提交
1528 1529 1530 1531 1532
};
let promise = sms.encodeMms(mmsInformation);
promise.then(data => {
    console.log(`encodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1533
    console.error(`encodeMms failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1534 1535 1536
});
```

S
shawn_he 已提交
1537
## ShortMessage
S
shawn_he 已提交
1538 1539 1540

Defines an SMS message instance.

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

S
shawn_he 已提交
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555
|         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 已提交
1556 1557


S
shawn_he 已提交
1558
## ShortMessageClass
S
shawn_he 已提交
1559

S
shawn_he 已提交
1560
Enumerates SMS message types.
S
shawn_he 已提交
1561

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

S
shawn_he 已提交
1564 1565 1566 1567 1568 1569 1570
| 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 已提交
1571 1572


S
shawn_he 已提交
1573
## SendMessageOptions
S
shawn_he 已提交
1574

S
shawn_he 已提交
1575
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 已提交
1576

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

S
shawn_he 已提交
1579
|       Name      | Type                                                        | Mandatory| Description                                                        |
S
shawn_he 已提交
1580
| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
1581 1582 1583 1584
| 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 已提交
1585
| 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 已提交
1586 1587
| 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 已提交
1588 1589


S
shawn_he 已提交
1590
## ISendShortMessageCallback
S
shawn_he 已提交
1591

S
shawn_he 已提交
1592 1593 1594
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 已提交
1595

S
shawn_he 已提交
1596 1597
|   Name    | Type                           | Mandatory|                                               Description                                        |
| ---------- | ------------------------------- | ---- | ----------------------------------------------------------------------------------------- |
S
shawn_he 已提交
1598
| 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 已提交
1599 1600
| result     | [SendSmsResult](#sendsmsresult) | Yes  | SMS message sending result.                                                                            |
| url        | string                          | Yes  | URI for storing the sent SMS message.                                                                       |
S
shawn_he 已提交
1601 1602


S
shawn_he 已提交
1603
## IDeliveryShortMessageCallback
S
shawn_he 已提交
1604

S
shawn_he 已提交
1605
Provides the callback for the SMS message delivery report.
S
shawn_he 已提交
1606 1607

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

S
shawn_he 已提交
1609
| Name| Type               | Mandatory| Description          |
S
shawn_he 已提交
1610 1611
| ---- | ------------------- | ---- | -------------- |
| pdu  | Array&lt;number&gt; | Yes  | SMS message delivery report.|
S
shawn_he 已提交
1612 1613


S
shawn_he 已提交
1614
## SendSmsResult
S
shawn_he 已提交
1615

S
shawn_he 已提交
1616
Enumerates SMS message sending results.
S
shawn_he 已提交
1617

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

S
shawn_he 已提交
1620
| Name                                | Value  | Description                                                  |
S
shawn_he 已提交
1621
| ------------------------------------ | ---- | ------------------------------------------------------ |
S
shawn_he 已提交
1622 1623
| 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 已提交
1624
| SEND_SMS_FAILURE_RADIO_OFF           | 2    | Failed to send the SMS message because the modem is shut down.                  |
S
shawn_he 已提交
1625
| 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 已提交
1626 1627 1628 1629 1630

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

Defines the MMS message information.

S
shawn_he 已提交
1631
**System API**: This is a system API.
S
shawn_he 已提交
1632 1633 1634

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

S
shawn_he 已提交
1635 1636 1637 1638
|     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 已提交
1639 1640 1641 1642 1643 1644
| attachment  | Array<[MmsAttachment](#mmsattachment8)\>                     | No  | Attachment.     |

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

Defines an MMS message sending request.

S
shawn_he 已提交
1645
**System API**: This is a system API.
S
shawn_he 已提交
1646 1647 1648

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

S
shawn_he 已提交
1649
|       Name      | Type                                | Mandatory| Description        |
S
shawn_he 已提交
1650 1651 1652 1653 1654
| ---------------- | ------------------------------------ | ---- | ------------ |
| 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 已提交
1655
| to               | Array<[MmsAddress](#mmsaddress8)\>   | No  | Destination address.      |
S
shawn_he 已提交
1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670
| 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 已提交
1671
**System API**: This is a system API.
S
shawn_he 已提交
1672 1673 1674

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

S
shawn_he 已提交
1675
|     Name     | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1676 1677 1678 1679 1680 1681 1682 1683 1684 1685
| ------------- | ---------------------------------- | ---- | -------- |
| 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 已提交
1686
**System API**: This is a system API.
S
shawn_he 已提交
1687 1688 1689

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

S
shawn_he 已提交
1690
|      Name      | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1691 1692 1693 1694 1695 1696 1697
| --------------- | ---------------------------------- | ---- | -------- |
| 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 已提交
1698
| from            | [MmsAddress](#mmsaddress8)         | No  | Source address.    |
S
shawn_he 已提交
1699 1700 1701 1702 1703 1704 1705 1706
| 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 已提交
1707
**System API**: This is a system API.
S
shawn_he 已提交
1708 1709 1710

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

S
shawn_he 已提交
1711
|      Name    | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1712 1713 1714 1715 1716 1717 1718 1719 1720
| ------------- | ---------------------------------- | ---- | -------- |
| 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 已提交
1721
**System API**: This is a system API.
S
shawn_he 已提交
1722 1723 1724

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

S
shawn_he 已提交
1725
|      Name     | Type                                | Mandatory| Description    |
S
shawn_he 已提交
1726 1727 1728 1729 1730
| -------------- | ------------------------------------ | ---- | -------- |
| transactionId  | string                               | Yes  | Transaction ID.  |
| messageId      | string                               | Yes  | Message ID.  |
| date           | number                               | Yes  | Date.    |
| contentType    | string                               | Yes  | Content type.|
S
shawn_he 已提交
1731 1732 1733
| to             | Array<[MmsAddress](#mmsaddress8)\>   | Yes  | Destination address.  |
| version        | [MmsVersionType](#mmsversiontype8)   | Yes  | Version.    |
| from           | [MmsAddress](#mmsaddress8)           | No  | Source address.    |
S
shawn_he 已提交
1734 1735
| cc             | Array<[MmsAddress](#mmsaddress8)\>   | No  | Carbon copy.    |
| subject        | string                               | No  | Subject.    |
S
shawn_he 已提交
1736
| priority       | [MmsPriorityType](#mmsprioritytype8) | No  | Priority.  |
S
shawn_he 已提交
1737 1738 1739 1740 1741 1742 1743 1744 1745
| 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 已提交
1746
**System API**: This is a system API.
S
shawn_he 已提交
1747 1748 1749

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

S
shawn_he 已提交
1750
|    Name   | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1751 1752 1753
| ---------- | ---------------------------------- | ---- | -------- |
| version    | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
| messageId  | string                             | Yes  | Message ID.  |
S
shawn_he 已提交
1754 1755
| to         | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.  |
| from       | [MmsAddress](#mmsaddress8)         | Yes  | Source address.    |
S
shawn_he 已提交
1756 1757 1758
| date       | number                             | Yes  | Date.    |
| readStatus | number                             | Yes  | Read status.|

S
shawn_he 已提交
1759 1760 1761 1762
## MmsReadRecInd<sup>8+</sup>

Defines the MMS message reading index.

S
shawn_he 已提交
1763
**System API**: This is a system API.
S
shawn_he 已提交
1764 1765 1766

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

S
shawn_he 已提交
1767
|    Name   | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1768
| ---------- | ---------------------------------- | ---- | -------- |
S
shawn_he 已提交
1769
| version    | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
S
shawn_he 已提交
1770
| messageId  | string                             | Yes  | Message ID.  |
S
shawn_he 已提交
1771 1772 1773
| to         | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.  |
| from       | [MmsAddress](#mmsaddress8)         | Yes  | Source address.    |
| readStatus | number                             | Yes  | Read status.|
S
shawn_he 已提交
1774 1775
| date       | number                             | No  | Date.    |

S
shawn_he 已提交
1776 1777 1778 1779
## MmsAttachment<sup>8+</sup>

Defines the attachment of an MMS message.

S
shawn_he 已提交
1780
**System API**: This is a system API.
S
shawn_he 已提交
1781 1782 1783

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

S
shawn_he 已提交
1784
|          Name          | Type                                | Mandatory| Description              |
S
shawn_he 已提交
1785 1786 1787 1788 1789 1790 1791 1792
| ----------------------- | ------------------------------------ | ---- | ------------------ |
| 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 已提交
1793
| inBuff                  | Array<number\>                       | No  | Whether the message is in the buffer.          |
S
shawn_he 已提交
1794 1795 1796 1797 1798 1799 1800
| fileName                | string                               | No  | File name.            |
| charset                 | [MmsCharSets](#mmscharsets8)         | No  | Character set.            |

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

Defines an MMSC address.

S
shawn_he 已提交
1801
**System API**: This is a system API.
S
shawn_he 已提交
1802 1803 1804

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

S
shawn_he 已提交
1805
|   Name | Type                        | Mandatory| Description  |
S
shawn_he 已提交
1806
| ------- | ---------------------------- | ---- | ------ |
S
shawn_he 已提交
1807
| address | string                       | Yes  | Network address.  |
S
shawn_he 已提交
1808 1809 1810 1811
| charset | [MmsCharSets](#mmscharsets8) | Yes  | Character set.|

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

S
shawn_he 已提交
1812
Message type.
S
shawn_he 已提交
1813

S
shawn_he 已提交
1814
**System API**: This is a system API.
S
shawn_he 已提交
1815 1816 1817

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

S
shawn_he 已提交
1818
|          Name            | Value  | Description                |
S
shawn_he 已提交
1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833
| ------------------------- | ---- | -------------------- |
| 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 已提交
1834
**System API**: This is a system API.
S
shawn_he 已提交
1835 1836 1837

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

S
shawn_he 已提交
1838
|    Name   | Value  | Description          |
S
shawn_he 已提交
1839 1840 1841 1842 1843 1844 1845 1846 1847
| ---------- | ---- | -------------- |
| 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 已提交
1848
**System API**: This is a system API.
S
shawn_he 已提交
1849 1850 1851

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

S
shawn_he 已提交
1852
|      Name      | Value  | Description       |
S
shawn_he 已提交
1853 1854 1855 1856 1857 1858 1859 1860 1861 1862
| --------------- | ---- | ----------- |
| 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 已提交
1863
**System API**: This is a system API.
S
shawn_he 已提交
1864 1865 1866

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

S
shawn_he 已提交
1867
|      Name      | Value    | Description               |
S
shawn_he 已提交
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887
| --------------- | ------ | ------------------- |
| 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 已提交
1888
**System API**: This is a system API.
S
shawn_he 已提交
1889 1890 1891

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

S
shawn_he 已提交
1892
|    Name   | Value  | Description    |
S
shawn_he 已提交
1893 1894 1895 1896 1897 1898 1899 1900 1901
| ---------- | ---- | -------- |
| FROM_DATA  | 0    | Data source.|
| ATTACHMENT | 1    | Attachment.    |
| INLINE     | 2    | Inlining.    |

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

Enumerates report types.

S
shawn_he 已提交
1902
**System API**: This is a system API.
S
shawn_he 已提交
1903 1904 1905

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

S
shawn_he 已提交
1906
|  Name  | Value  | Description|
S
shawn_he 已提交
1907 1908 1909 1910
| ------- | ---- | ---- |
| MMS_YES | 128  | YES  |
| MMS_NO  | 129  | NO   |

S
shawn_he 已提交
1911
## CBConfigOptions<sup>7+</sup>
S
shawn_he 已提交
1912 1913 1914

Defines the cell broadcast configuration options.

S
shawn_he 已提交
1915
**System API**: This is a system API.
S
shawn_he 已提交
1916 1917 1918

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

S
shawn_he 已提交
1919
|      Name     | Type                | Mandatory| Description        |
S
shawn_he 已提交
1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930
| -------------- | -------------------- | ---- | ------------ |
| 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 已提交
1931
**System API**: This is a system API.
S
shawn_he 已提交
1932 1933 1934

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

S
shawn_he 已提交
1935
|           Name           | Value  | Description                       |
S
shawn_he 已提交
1936 1937 1938 1939 1940 1941 1942 1943 1944
| ------------------------- | ---- | --------------------------- |
| 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 已提交
1945
RAN type.
S
shawn_he 已提交
1946

S
shawn_he 已提交
1947
**System API**: This is a system API.
S
shawn_he 已提交
1948 1949 1950

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

S
shawn_he 已提交
1951
|   Name   | Value  | Description|
S
shawn_he 已提交
1952 1953 1954 1955 1956 1957 1958 1959
| --------- | ---- | ---- |
| TYPE_GSM  | 1    | GSM  |
| TYPE_CDMA | 2    | CMDA |

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

Enumerates SMS encoding schemes.

S
shawn_he 已提交
1960
**System API**: This is a system API.
S
shawn_he 已提交
1961 1962 1963

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

S
shawn_he 已提交
1964
|         Name        | Value  | Description        |
S
shawn_he 已提交
1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
| -------------------- | ---- | ------------ |
| 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 已提交
1975
**System API**: This is a system API.
S
shawn_he 已提交
1976 1977 1978

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

S
shawn_he 已提交
1979
|  Name | Type                                  | Mandatory| Description          |
S
shawn_he 已提交
1980 1981 1982 1983
| ------ | -------------------------------------- | ---- | -------------- |
| slotId | number                                 | Yes  | Card slot ID.        |
| smsc   | string                                 | Yes  | Short message service center.|
| pdu    | string                                 | Yes  | Protocol data unit.  |
S
shawn_he 已提交
1984
| status | [SimMessageStatus](#simmessagestatus7) | Yes  | Status.          |
S
shawn_he 已提交
1985 1986 1987 1988 1989

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

Defines the updating SIM message options.

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

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

S
shawn_he 已提交
1994
|   Name   | Type                                  | Mandatory| Description          |
S
shawn_he 已提交
1995 1996 1997 1998 1999 2000 2001
| --------- | -------------------------------------- | ---- | -------------- |
| 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 已提交
2002
## SimShortMessage<sup>7+</sup>
S
shawn_he 已提交
2003 2004 2005

Defines a SIM message.

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

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

S
shawn_he 已提交
2010
|       Name      | Type                                  | Mandatory| Description         |
S
shawn_he 已提交
2011 2012 2013 2014 2015 2016 2017 2018 2019
| ---------------- | -------------------------------------- | ---- | ------------- |
| 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 已提交
2020
**System API**: This is a system API.
S
shawn_he 已提交
2021 2022 2023

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

S
shawn_he 已提交
2024
|    Name  | Type                              | Mandatory| Description  |
S
shawn_he 已提交
2025 2026 2027
| --------- | ---------------------------------- | ---- | ------ |
| messageId | string                             | Yes  | Message ID.|
| date      | number                             | Yes  | Date.  |
S
shawn_he 已提交
2028 2029
| to        | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.|
| status    | number                             | Yes  | Status  |
S
shawn_he 已提交
2030 2031 2032 2033 2034 2035
| version   | [MmsVersionType](#mmsversiontype8) | Yes  | Version.  |

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

Defines an MMS response index.

S
shawn_he 已提交
2036
**System API**: This is a system API.
S
shawn_he 已提交
2037 2038 2039

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

S
shawn_he 已提交
2040
|     Name     | Type                              | Mandatory| Description    |
S
shawn_he 已提交
2041 2042
| ------------- | ---------------------------------- | ---- | -------- |
| transactionId | string                             | Yes  | Event ID.  |
S
shawn_he 已提交
2043
| status        | number                             | Yes  | Status    |
S
shawn_he 已提交
2044 2045 2046 2047 2048 2049 2050
| version       | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
| reportAllowed | [ReportType](#reporttype8)         | No  | Report allowed.|

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

Defines the SMS message segment information.

S
shawn_he 已提交
2051
**System API**: This is a system API.
S
shawn_he 已提交
2052 2053 2054

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

S
shawn_he 已提交
2055
|        Name         | Type                                    | Mandatory| Description        |
S
shawn_he 已提交
2056 2057 2058 2059 2060
| -------------------- | ---------------------------------------- | ---- | ------------ |
| splitCount           | number                                   | Yes  | Split count.    |
| encodeCount          | number                                   | Yes  | Encoding count.    |
| encodeCountRemaining | number                                   | Yes  | Remaining encoding count.|
| scheme               | [SmsEncodingScheme](#smsencodingscheme8) | Yes  | Encoding scheme.|