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

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

S
shawn_he 已提交
5
>**NOTE**
S
shawn_he 已提交
6
>
Z
zengyawen 已提交
7
>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
S
shawn_he 已提交
8 9 10

## Modules to Import

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

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

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

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

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

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

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

S
shawn_he 已提交
31
**Example**
S
shawn_he 已提交
32

S
shawn_he 已提交
33
```js
S
shawn_he 已提交
34 35 36 37 38 39 40
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 已提交
41 42


S
shawn_he 已提交
43
## sms.createMessage
S
shawn_he 已提交
44

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

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

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

S
shawn_he 已提交
51
**Parameters**
S
shawn_he 已提交
52

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

S
shawn_he 已提交
58
**Return value**
S
shawn_he 已提交
59

S
shawn_he 已提交
60
| Type                                        | Description                             |
S
shawn_he 已提交
61
| -------------------------------------------- | --------------------------------- |
S
shawn_he 已提交
62
| Promise&lt;[ShortMessage](#shortmessage)&gt; | Promise used to return the result.|
S
shawn_he 已提交
63

S
shawn_he 已提交
64
**Example**
S
shawn_he 已提交
65

S
shawn_he 已提交
66
```js
S
shawn_he 已提交
67 68 69 70 71 72 73
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 已提交
74
    console.error(`createMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
75 76
});
```
S
shawn_he 已提交
77 78 79 80 81 82 83

## sms.sendMessage

sendMessage(options: SendMessageOptions): void

Sends an SMS message.

S
shawn_he 已提交
84
**Required permissions**: ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
85 86

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

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

S
shawn_he 已提交
90
| Name | Type                                     | Mandatory| Description                                                        |
S
shawn_he 已提交
91
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
92
| options | [SendMessageOptions](#sendmessageoptions) | Yes  | Options (including the callback) for sending an SMS message.|
S
shawn_he 已提交
93

S
shawn_he 已提交
94 95 96 97 98 99 100 101 102 103 104 105 106
**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 已提交
107
**Example**
S
shawn_he 已提交
108

S
shawn_he 已提交
109
```js
S
shawn_he 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122 123
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 已提交
124 125


S
shawn_he 已提交
126
## sms.getDefaultSmsSlotId<sup>7+</sup>
S
shawn_he 已提交
127

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

S
shawn_he 已提交
130
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 已提交
131

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

S
shawn_he 已提交
134
**Parameters**
S
shawn_he 已提交
135

S
shawn_he 已提交
136
| Name  | Type                       | Mandatory| Description                                    |
S
shawn_he 已提交
137
| -------- | --------------------------- | ---- | ---------------------------------------- |
S
shawn_he 已提交
138
| 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 已提交
139

S
shawn_he 已提交
140
**Example**
S
shawn_he 已提交
141

S
shawn_he 已提交
142
```js
S
shawn_he 已提交
143 144 145 146
sms.getDefaultSmsSlotId((err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
147 148


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

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

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

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

S
shawn_he 已提交
157
**Return value**
S
shawn_he 已提交
158

S
shawn_he 已提交
159
| Type           | Description                                                        |
S
shawn_he 已提交
160
| --------------- | ------------------------------------------------------------ |
S
shawn_he 已提交
161
| Promise&lt;number&gt; | Promise used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
162

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

S
shawn_he 已提交
165
```js
S
shawn_he 已提交
166
let promise = sms.getDefaultSmsSlotId();
S
shawn_he 已提交
167 168 169
promise.then(data => {
    console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
170
    console.error(`getDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
171 172
});
```
S
shawn_he 已提交
173

S
shawn_he 已提交
174 175
## sms.setDefaultSmsSlotId<sup>7+</sup>

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

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

S
shawn_he 已提交
180
**System API**: This is a system API.
S
shawn_he 已提交
181

S
shawn_he 已提交
182
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE
S
shawn_he 已提交
183 184 185 186 187 188 189

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

**Parameters**

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

S
shawn_he 已提交
193 194
**Error codes**

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

S
shawn_he 已提交
197 198 199 200 201 202 203 204 205 206
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
| 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 已提交
207 208 209
**Example**

```js
S
shawn_he 已提交
210 211
sms.setDefaultSmsSlotId(0, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}.`);
S
shawn_he 已提交
212 213 214 215 216 217 218 219
});
```


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

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

S
shawn_he 已提交
220
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 已提交
221

S
shawn_he 已提交
222
**System API**: This is a system API.
S
shawn_he 已提交
223

S
shawn_he 已提交
224
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE
S
shawn_he 已提交
225 226 227 228 229 230 231

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

**Parameters**

| Name| Type  | Mandatory| Description                                                        |
| ------ | ------ | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
232
| 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 已提交
233 234 235

**Return value**

S
shawn_he 已提交
236 237 238 239 240 241
| Type           | Description                           |
| --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.|

**Error codes**

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

S
shawn_he 已提交
244 245 246 247 248 249 250 251 252
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
| 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 已提交
253 254 255 256 257

**Example**

```js
let promise = sms.setDefaultSmsSlotId(0);
S
shawn_he 已提交
258 259 260
promise.then(() => {
    console.log(`setDefaultSmsSlotId success.`);
}).catch((err) => {
S
shawn_he 已提交
261
    console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
262 263
});
```
S
shawn_he 已提交
264

S
shawn_he 已提交
265
## sms.setSmscAddr<sup>7+</sup>
S
shawn_he 已提交
266 267 268

setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback<void\>\): void

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

S
shawn_he 已提交
271
**System API**: This is a system API.
S
shawn_he 已提交
272

S
shawn_he 已提交
273
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
274 275

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

S
shawn_he 已提交
277
**Parameters**
S
shawn_he 已提交
278

S
shawn_he 已提交
279
| Name  | Type                     | Mandatory| Description                                     |
S
shawn_he 已提交
280
| -------- | ------------------------- | ---- | ----------------------------------------- |
S
shawn_he 已提交
281
| slotId   | number                    | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
282
| smscAddr | string                    | Yes  | SMSC address.                       |
S
shawn_he 已提交
283
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                               |
S
shawn_he 已提交
284

S
shawn_he 已提交
285 286
**Error codes**

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

S
shawn_he 已提交
289 290 291 292 293 294 295 296 297
| 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 已提交
298
**Example**
S
shawn_he 已提交
299

S
shawn_he 已提交
300
```js
S
shawn_he 已提交
301 302
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
S
shawn_he 已提交
303 304
sms.setSmscAddr(slotId, smscAddr, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
305 306
});
```
S
shawn_he 已提交
307 308


S
shawn_he 已提交
309
## sms.setSmscAddr<sup>7+</sup>
S
shawn_he 已提交
310

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

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

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

S
shawn_he 已提交
317
**Required permissions**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
318 319

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

S
shawn_he 已提交
321
**Parameters**
S
shawn_he 已提交
322

S
shawn_he 已提交
323
| Name  | Type  | Mandatory| Description                                     |
S
shawn_he 已提交
324
| -------- | ------ | ---- | ----------------------------------------- |
S
shawn_he 已提交
325
| slotId   | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
326
| smscAddr | string | Yes  | SMSC address.                       |
S
shawn_he 已提交
327

S
shawn_he 已提交
328
**Return value**
S
shawn_he 已提交
329

S
shawn_he 已提交
330
| Type               | Description                           |
S
shawn_he 已提交
331 332
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
S
shawn_he 已提交
333

S
shawn_he 已提交
334 335
**Error codes**

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

S
shawn_he 已提交
338 339 340 341 342 343 344 345 346
| 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 已提交
347
**Example**
S
shawn_he 已提交
348

S
shawn_he 已提交
349
```js
S
shawn_he 已提交
350 351 352
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
let promise = sms.setSmscAddr(slotId, smscAddr);
S
shawn_he 已提交
353 354 355
promise.then(() => {
    console.log(`setSmscAddr success.`);
}).catch((err) => {
S
shawn_he 已提交
356
    console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
357 358
});
```
S
shawn_he 已提交
359 360


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

getSmscAddr\(slotId: number, callback: AsyncCallback<string\>\): void

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

S
shawn_he 已提交
367
**System API**: This is a system API.
S
shawn_he 已提交
368

S
shawn_he 已提交
369
**Required permissions**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
S
shawn_he 已提交
370 371

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

S
shawn_he 已提交
373
**Parameters**
S
shawn_he 已提交
374

S
shawn_he 已提交
375
| Name  | Type                       | Mandatory| Description                                     |
S
shawn_he 已提交
376
| -------- | --------------------------- | ---- | ----------------------------------------- |
S
shawn_he 已提交
377 378
| 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 已提交
379

S
shawn_he 已提交
380 381
**Error codes**

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

S
shawn_he 已提交
384 385 386 387 388 389 390 391 392
| 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 已提交
393
**Example**
S
shawn_he 已提交
394

S
shawn_he 已提交
395
```js
S
shawn_he 已提交
396 397 398 399 400
let slotId = 0;
sms.getSmscAddr(slotId, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
401 402


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

getSmscAddr\(slotId: number\): Promise<string\>

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

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

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

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

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

S
shawn_he 已提交
417
| Name| Type  | Mandatory| Description                                     |
S
shawn_he 已提交
418
| ------ | ------ | ---- | ----------------------------------------- |
S
shawn_he 已提交
419
| slotId | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
420

S
shawn_he 已提交
421
**Return value**
S
shawn_he 已提交
422

S
shawn_he 已提交
423
| Type                 | Description                                         |
S
shawn_he 已提交
424 425
| --------------------- | --------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.|
S
shawn_he 已提交
426

S
shawn_he 已提交
427 428
**Error codes**

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

S
shawn_he 已提交
431 432 433 434 435 436 437 438 439
| 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 已提交
440
**Example**
S
shawn_he 已提交
441

S
shawn_he 已提交
442
```js
S
shawn_he 已提交
443 444 445 446 447
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 已提交
448
    console.error(`getSmscAddr failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
449 450
});
```
S
shawn_he 已提交
451

S
shawn_he 已提交
452
## sms.hasSmsCapability<sup>7+</sup>
S
shawn_he 已提交
453 454 455

hasSmsCapability(): boolean

S
shawn_he 已提交
456
Checks whether the current device can send and receive SMS messages. This API works in synchronous mode.
S
shawn_he 已提交
457 458 459

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

S
shawn_he 已提交
460
**Return value**
S
shawn_he 已提交
461 462 463 464 465

| 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 已提交
466
```js
S
shawn_he 已提交
467 468 469
let result = sms.hasSmsCapability(); 
console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
```
S
shawn_he 已提交
470

S
shawn_he 已提交
471 472 473 474 475 476
## sms.splitMessage<sup>8+</sup>

splitMessage(content: string, callback: AsyncCallback<Array<string\>>): void

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

S
shawn_he 已提交
477
**System API**: This is a system API.
S
shawn_he 已提交
478

S
shawn_he 已提交
479
**Required permissions**: ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
480 481 482 483 484 485 486 487 488 489

**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 已提交
490 491
**Error codes**

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

S
shawn_he 已提交
494 495 496 497 498 499 500 501 502
| 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 已提交
503 504 505
**Example**

```js
S
shawn_he 已提交
506
let content = "long message";
S
shawn_he 已提交
507 508 509 510 511 512 513 514 515 516 517 518
sms.splitMessage(content, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


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

splitMessage(content: string): Promise<Array<string\>>

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

S
shawn_he 已提交
519
**System API**: This is a system API.
S
shawn_he 已提交
520

S
shawn_he 已提交
521
**Required permissions**: ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536

**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 已提交
537 538
**Error codes**

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

S
shawn_he 已提交
541 542 543 544 545 546 547 548 549
| 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 已提交
550 551 552
**Example**

```js
S
shawn_he 已提交
553
let content = "long message";
S
shawn_he 已提交
554 555 556 557
let promise = sms.splitMessage(content);
promise.then(data => {
    console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
558
    console.error(`splitMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
559 560 561 562 563 564 565 566 567
});
```

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

addSimMessage(options: SimMessageOptions, callback: AsyncCallback<void\>): void

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

S
shawn_he 已提交
568
**System API**: This is a system API.
S
shawn_he 已提交
569

S
shawn_he 已提交
570
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
571 572 573 574 575 576 577 578 579 580

**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 已提交
581 582
**Error codes**

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

S
shawn_he 已提交
585 586 587 588 589 590 591 592 593
| 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 已提交
594 595 596 597
**Example**

```js
let simMessageOptions = {
S
shawn_he 已提交
598 599 600 601
    slotId: 0,
    smsc: "test",
    pdu: "xxxxxx",
    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
S
shawn_he 已提交
602
};
S
shawn_he 已提交
603 604
sms.addSimMessage(simMessageOptions, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
605 606 607 608 609 610 611 612 613 614
});
```


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

addSimMessage(options: SimMessageOptions): Promise<void\>

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

S
shawn_he 已提交
615
**System API**: This is a system API.
S
shawn_he 已提交
616

S
shawn_he 已提交
617
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632

**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 已提交
633 634
**Error codes**

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

S
shawn_he 已提交
637 638 639 640 641 642 643 644 645
| 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 已提交
646 647 648 649
**Example**

```js
let simMessageOptions = {
S
shawn_he 已提交
650 651 652 653
    slotId: 0,
    smsc: "test",
    pdu: "xxxxxx",
    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
S
shawn_he 已提交
654 655
};
let promise = sms.addSimMessage(simMessageOptions);
S
shawn_he 已提交
656 657 658
promise.then(() => {
    console.log(`addSimMessage success.`);
}).catch((err) => {
S
shawn_he 已提交
659
    console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
660 661 662 663 664 665 666 667 668
});
```

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

delSimMessage(slotId: number, msgIndex: number, callback: AsyncCallback<void\>): void

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

S
shawn_he 已提交
669
**System API**: This is a system API.
S
shawn_he 已提交
670

S
shawn_he 已提交
671
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
672 673 674 675 676 677 678 679 680 681 682

**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 已提交
683 684
**Error codes**

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

S
shawn_he 已提交
687 688 689 690 691 692 693 694 695
| 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 已提交
696 697 698 699 700
**Example**

```js
let slotId = 0;
let msgIndex = 1;
S
shawn_he 已提交
701 702
sms.delSimMessage(slotId, msgIndex, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
703 704 705 706 707 708 709 710 711 712
});
```


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

delSimMessage(slotId: number, msgIndex: number): Promise<void\>

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

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

S
shawn_he 已提交
715
**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
S
shawn_he 已提交
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731

**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 已提交
732 733
**Error codes**

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

S
shawn_he 已提交
736 737 738 739 740 741 742 743 744
| 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 已提交
745 746 747 748 749 750
**Example**

```js
let slotId = 0;
let msgIndex = 1;
let promise = sms.delSimMessage(slotId, msgIndex);
S
shawn_he 已提交
751 752 753
promise.then(() => {
    console.log(`delSimMessage success.`);
}).catch((err) => {
S
shawn_he 已提交
754
    console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
755 756 757 758 759 760 761 762 763
});
```

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

updateSimMessage(options: UpdateSimMessageOptions, callback: AsyncCallback<void\>): void

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

S
shawn_he 已提交
764
**System API**: This is a system API.
S
shawn_he 已提交
765

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

**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 已提交
777 778
**Error codes**

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

S
shawn_he 已提交
781 782 783 784 785 786 787 788 789
| 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 已提交
790 791 792 793
**Example**

```js
let updateSimMessageOptions = {
S
shawn_he 已提交
794 795 796
    slotId: 0,
    msgIndex: 1,
    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
S
shawn_he 已提交
797 798
    pdu: "xxxxxxx",
    smsc: "test"
S
shawn_he 已提交
799
};
S
shawn_he 已提交
800 801
sms.updateSimMessage(updateSimMessageOptions, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
802 803 804 805 806 807 808 809 810 811
});
```


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

updateSimMessage(options: UpdateSimMessageOptions): Promise<void\>

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

S
shawn_he 已提交
812
**System API**: This is a system API.
S
shawn_he 已提交
813

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

**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 已提交
830 831
**Error codes**

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

S
shawn_he 已提交
834 835 836 837 838 839 840 841 842
| 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 已提交
843 844 845 846
**Example**

```js
let updateSimMessageOptions = {
S
shawn_he 已提交
847 848 849
    slotId: 0,
    msgIndex: 1,
    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
S
shawn_he 已提交
850 851
    pdu: "xxxxxxx",
    smsc: "test"
S
shawn_he 已提交
852 853
};
let promise = sms.updateSimMessage(updateSimMessageOptions);
S
shawn_he 已提交
854 855 856
promise.then(() => {
    console.log(`updateSimMessage success.`);
}).catch((err) => {
S
shawn_he 已提交
857
    console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
858 859 860 861 862 863 864 865 866
});
```

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

getAllSimMessages(slotId: number, callback: AsyncCallback<Array<SimShortMessage\>>): void

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

S
shawn_he 已提交
867
**System API**: This is a system API.
S
shawn_he 已提交
868

S
shawn_he 已提交
869
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
870 871 872 873 874 875 876 877

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

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

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

S
shawn_he 已提交
884 885 886 887 888 889 890 891 892
| 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 已提交
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
**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>

getAllSimMessages(slotId: number): Promise<Array<SimShortMessage\>>

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

S
shawn_he 已提交
909
**System API**: This is a system API.
S
shawn_he 已提交
910

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

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

S
shawn_he 已提交
927 928
**Error codes**

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

S
shawn_he 已提交
931 932 933 934 935 936 937 938 939
| 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 已提交
940 941 942 943 944 945 946 947
**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 已提交
948
    console.error(`getAllSimMessages failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
949 950 951 952 953 954 955 956 957
});
```

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

setCBConfig(options: CBConfigOptions, callback: AsyncCallback<void\>): void

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

S
shawn_he 已提交
958
**System API**: This is a system API.
S
shawn_he 已提交
959

S
shawn_he 已提交
960
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
961 962 963 964 965 966 967

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

**Parameters**

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

S
shawn_he 已提交
971 972
**Error codes**

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

S
shawn_he 已提交
975 976 977 978 979 980 981 982 983
| 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 已提交
984 985 986 987
**Example**

```js
let cbConfigOptions = {
S
shawn_he 已提交
988 989 990 991 992
    slotId: 0,
    enable: true,
    startMessageId: 100,
    endMessageId: 200,
    ranType: sms.RanType.TYPE_GSM
S
shawn_he 已提交
993
};
S
shawn_he 已提交
994 995
sms.setCBConfig(cbConfigOptions, (err) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
996 997 998 999 1000 1001 1002 1003 1004 1005
});
```


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

setCBConfig(options: CBConfigOptions): Promise<void\>

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

S
shawn_he 已提交
1006
**System API**: This is a system API.
S
shawn_he 已提交
1007

S
shawn_he 已提交
1008
**Required permissions**: ohos.permission.RECEIVE_SMS
S
shawn_he 已提交
1009 1010 1011 1012 1013 1014 1015

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

**Parameters**

| Name | Type                                | Mandatory| Description        |
| ------- | ------------------------------------ | ---- | ------------ |
S
shawn_he 已提交
1016
| options | [CBConfigOptions](#cbconfigoptions7) | Yes  | Cell broadcast configuration options.|
S
shawn_he 已提交
1017 1018 1019 1020 1021 1022 1023

**Return value**

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

S
shawn_he 已提交
1024 1025
**Error codes**

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

S
shawn_he 已提交
1028 1029 1030 1031 1032 1033 1034 1035 1036
| 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 已提交
1037 1038 1039 1040
**Example**

```js
let cbConfigOptions = {
S
shawn_he 已提交
1041 1042 1043 1044 1045
    slotId: 0,
    enable: true,
    startMessageId: 100,
    endMessageId: 200,
    ranType: sms.RanType.TYPE_GSM
S
shawn_he 已提交
1046 1047
};
let promise = sms.setCBConfig(cbConfigOptions);
S
shawn_he 已提交
1048 1049 1050
promise.then(() => {
    console.log(`setCBConfig success.`);
}).catch((err) => {
S
shawn_he 已提交
1051
    console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1052 1053 1054 1055 1056 1057 1058 1059 1060
});
```

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

getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback<SmsSegmentsInfo\>): void

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

S
shawn_he 已提交
1061
**System API**: This is a system API.
S
shawn_he 已提交
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071

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

**Error codes**

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

S
shawn_he 已提交
1078 1079 1080 1081 1082 1083 1084
| 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 已提交
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101

**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>

getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean): Promise<SmsSegmentsInfo\>

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

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

**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 已提交
1111
| message   | string  | Yes  | SMS message.                                     |
S
shawn_he 已提交
1112 1113 1114 1115 1116 1117
| force7bit | boolean | Yes  | Whether to use 7-bit coding.                         |

**Return value**

| Type                                                   | Description                         |
| ------------------------------------------------------- | ----------------------------- |
S
shawn_he 已提交
1118 1119 1120 1121
| Promise&lt;[SmsSegmentsInfo](#smssegmentsinfo8)&gt; | Promise used to return the result.|

**Error codes**

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

S
shawn_he 已提交
1124 1125 1126 1127 1128 1129 1130
| 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 已提交
1131 1132 1133 1134 1135 1136

**Example**

```js
let slotId = 0;
let promise = sms.getSmsSegmentsInfo(slotId, "message", false);
S
shawn_he 已提交
1137
promise.then(data => {
S
shawn_he 已提交
1138 1139
    console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1140
    console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1141 1142 1143 1144 1145
});
```

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

S
shawn_he 已提交
1146
isImsSmsSupported(slotId: number, callback: AsyncCallback<boolean\>): void
S
shawn_he 已提交
1147 1148 1149

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

S
shawn_he 已提交
1150
**System API**: This is a system API.
S
shawn_he 已提交
1151 1152 1153 1154 1155 1156 1157

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

**Parameters**

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

S
shawn_he 已提交
1161 1162
**Error codes**

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

S
shawn_he 已提交
1165 1166 1167 1168 1169 1170 1171 1172
| 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 已提交
1173 1174 1175
**Example**

```js
S
shawn_he 已提交
1176 1177
let slotId = 0;
sms.isImsSmsSupported(slotId, (err, data) => {
S
shawn_he 已提交
1178
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
S
shawn_he 已提交
1179 1180 1181 1182 1183 1184
});
```


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

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

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

S
shawn_he 已提交
1189
**System API**: This is a system API.
S
shawn_he 已提交
1190 1191 1192

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

S
shawn_he 已提交
1193 1194 1195 1196 1197 1198
**Parameters**

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

S
shawn_he 已提交
1199 1200 1201 1202 1203 1204
**Return value**

| Type                  | Description                   |
| ---------------------- | ----------------------- |
| Promise&lt;boolean&gt; | Promise 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 1211 1212 1213 1214 1215 1216
| 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 已提交
1217 1218 1219
**Example**

```js
S
shawn_he 已提交
1220 1221
let slotId = 0;
let promise = sms.isImsSmsSupported(slotId);
S
shawn_he 已提交
1222 1223 1224
promise.then(data => {
    console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1225
    console.error(`isImsSmsSupported failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1226 1227 1228 1229 1230 1231 1232 1233 1234
});
```

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

getImsShortMessageFormat(callback: AsyncCallback<string\>): void

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

S
shawn_he 已提交
1235
**System API**: This is a system API.
S
shawn_he 已提交
1236 1237 1238 1239 1240 1241 1242 1243 1244

**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 已提交
1245 1246
**Error codes**

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

S
shawn_he 已提交
1249 1250 1251 1252 1253 1254 1255 1256
| 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 已提交
1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271
**Example**

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


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

getImsShortMessageFormat(): Promise<string\>

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

S
shawn_he 已提交
1272
**System API**: This is a system API.
S
shawn_he 已提交
1273 1274 1275 1276 1277 1278 1279 1280 1281

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

**Return value**

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

S
shawn_he 已提交
1282 1283
**Error codes**

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

S
shawn_he 已提交
1286 1287 1288 1289 1290 1291 1292 1293
| 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 已提交
1294 1295 1296 1297 1298 1299 1300
**Example**

```js
let promise = sms.getImsShortMessageFormat();
promise.then(data => {
    console.log(`getImsShortMessageFormat success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1301
    console.error(`getImsShortMessageFormat failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1302 1303 1304 1305 1306 1307 1308 1309 1310
});
```

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

decodeMms(mmsFilePathName: string | Array<number\>, callback: AsyncCallback<MmsInformation\>): void

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

S
shawn_he 已提交
1311
**System API**: This is a system API.
S
shawn_he 已提交
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321

**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 已提交
1322 1323
**Error codes**

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

S
shawn_he 已提交
1326 1327 1328 1329 1330 1331 1332 1333
| 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 已提交
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349
**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>

decodeMms(mmsFilePathName: string | Array<number\>): Promise<MmsInformation\>

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

S
shawn_he 已提交
1350
**System API**: This is a system API.
S
shawn_he 已提交
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365

**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 已提交
1366 1367
**Error codes**

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

S
shawn_he 已提交
1370 1371 1372 1373 1374 1375 1376 1377
| 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 已提交
1378 1379 1380 1381
**Example**

```js
let mmsFilePathName = "filename";
S
shawn_he 已提交
1382
let promise = sms.decodeMms(mmsFilePathName);
S
shawn_he 已提交
1383 1384 1385
promise.then(data => {
    console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1386
    console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1387 1388 1389 1390 1391 1392 1393
});
```

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

encodeMms(mms: MmsInformation, callback: AsyncCallback<Array<number\>>): void

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

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

**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 已提交
1407 1408
**Error codes**

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

S
shawn_he 已提交
1411 1412 1413 1414 1415 1416 1417 1418
| 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 已提交
1419 1420 1421 1422
**Example**

```js
let mmsAcknowledgeInd = {
S
shawn_he 已提交
1423 1424 1425
    transactionId: "100",
    version: sms.MmsVersionType.MMS_VERSION_1_0,
    reportAllowed: sms.ReportType.MMS_YES
S
shawn_he 已提交
1426 1427
};
let mmsInformation = {
S
shawn_he 已提交
1428 1429
    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
    mmsType: mmsAcknowledgeInd
S
shawn_he 已提交
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440
};
sms.encodeMms(mmsInformation, (err, data) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


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

encodeMms(mms: MmsInformation): Promise<Array<number\>>

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

S
shawn_he 已提交
1443
**System API**: This is a system API.
S
shawn_he 已提交
1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458

**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 已提交
1459 1460
**Error codes**

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

S
shawn_he 已提交
1463 1464 1465 1466 1467 1468 1469 1470
| 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 已提交
1471 1472 1473 1474
**Example**

```js
let mmsAcknowledgeInd = {
S
shawn_he 已提交
1475 1476
    transactionId: "100",
    version: sms.MmsVersionType.MMS_VERSION_1_0,
S
shawn_he 已提交
1477
    reportAllowed: sms.ReportType.MMS_YES
S
shawn_he 已提交
1478 1479
};
let mmsInformation = {
S
shawn_he 已提交
1480
    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
S
shawn_he 已提交
1481
    mmsType: mmsAcknowledgeInd
S
shawn_he 已提交
1482 1483 1484 1485 1486
};
let promise = sms.encodeMms(mmsInformation);
promise.then(data => {
    console.log(`encodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1487
    console.error(`encodeMms failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1488 1489 1490
});
```

S
shawn_he 已提交
1491
## ShortMessage
S
shawn_he 已提交
1492 1493 1494

Defines an SMS message instance.

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

S
shawn_he 已提交
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509
|         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 已提交
1510 1511


S
shawn_he 已提交
1512
## ShortMessageClass
S
shawn_he 已提交
1513

S
shawn_he 已提交
1514
Enumerates SMS message types.
S
shawn_he 已提交
1515

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

S
shawn_he 已提交
1518 1519 1520 1521 1522 1523 1524
| 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 已提交
1525 1526


S
shawn_he 已提交
1527
## SendMessageOptions
S
shawn_he 已提交
1528

S
shawn_he 已提交
1529
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 已提交
1530

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

S
shawn_he 已提交
1533
|       Name      | Type                                                        | Mandatory| Description                                                        |
S
shawn_he 已提交
1534
| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
1535 1536 1537 1538
| 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 已提交
1539
| 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 已提交
1540 1541
| 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 已提交
1542 1543


S
shawn_he 已提交
1544
## ISendShortMessageCallback
S
shawn_he 已提交
1545

S
shawn_he 已提交
1546 1547 1548
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 已提交
1549

S
shawn_he 已提交
1550 1551
|   Name    | Type                           | Mandatory|                                               Description                                        |
| ---------- | ------------------------------- | ---- | ----------------------------------------------------------------------------------------- |
S
shawn_he 已提交
1552
| 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 已提交
1553 1554
| result     | [SendSmsResult](#sendsmsresult) | Yes  | SMS message sending result.                                                                            |
| url        | string                          | Yes  | URI for storing the sent SMS message.                                                                       |
S
shawn_he 已提交
1555 1556


S
shawn_he 已提交
1557
## IDeliveryShortMessageCallback
S
shawn_he 已提交
1558

S
shawn_he 已提交
1559
Provides the callback for the SMS message delivery report.
S
shawn_he 已提交
1560 1561

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

S
shawn_he 已提交
1563
| Name| Type               | Mandatory| Description          |
S
shawn_he 已提交
1564 1565
| ---- | ------------------- | ---- | -------------- |
| pdu  | Array&lt;number&gt; | Yes  | SMS message delivery report.|
S
shawn_he 已提交
1566 1567


S
shawn_he 已提交
1568
## SendSmsResult
S
shawn_he 已提交
1569

S
shawn_he 已提交
1570
Enumerates SMS message sending results.
S
shawn_he 已提交
1571

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

S
shawn_he 已提交
1574
| Name                                | Value  | Description                                                  |
S
shawn_he 已提交
1575
| ------------------------------------ | ---- | ------------------------------------------------------ |
S
shawn_he 已提交
1576 1577
| 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 已提交
1578
| SEND_SMS_FAILURE_RADIO_OFF           | 2    | Failed to send the SMS message because the modem is shut down.                  |
S
shawn_he 已提交
1579
| 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 已提交
1580 1581 1582 1583 1584

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

Defines the MMS message information.

S
shawn_he 已提交
1585
**System API**: This is a system API.
S
shawn_he 已提交
1586 1587 1588

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

S
shawn_he 已提交
1589 1590 1591 1592
|     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 已提交
1593 1594 1595 1596 1597 1598
| attachment  | Array<[MmsAttachment](#mmsattachment8)\>                     | No  | Attachment.     |

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

Defines an MMS message sending request.

S
shawn_he 已提交
1599
**System API**: This is a system API.
S
shawn_he 已提交
1600 1601 1602

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

S
shawn_he 已提交
1603
|       Name      | Type                                | Mandatory| Description        |
S
shawn_he 已提交
1604 1605 1606 1607 1608
| ---------------- | ------------------------------------ | ---- | ------------ |
| 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 已提交
1609
| to               | Array<[MmsAddress](#mmsaddress8)\>   | No  | Destination address.      |
S
shawn_he 已提交
1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624
| 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 已提交
1625
**System API**: This is a system API.
S
shawn_he 已提交
1626 1627 1628

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

S
shawn_he 已提交
1629
|     Name     | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1630 1631 1632 1633 1634 1635 1636 1637 1638 1639
| ------------- | ---------------------------------- | ---- | -------- |
| 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 已提交
1640
**System API**: This is a system API.
S
shawn_he 已提交
1641 1642 1643

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

S
shawn_he 已提交
1644
|      Name      | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1645 1646 1647 1648 1649 1650 1651
| --------------- | ---------------------------------- | ---- | -------- |
| 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 已提交
1652
| from            | [MmsAddress](#mmsaddress8)         | No  | Source address.    |
S
shawn_he 已提交
1653 1654 1655 1656 1657 1658 1659 1660
| 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 已提交
1661
**System API**: This is a system API.
S
shawn_he 已提交
1662 1663 1664

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

S
shawn_he 已提交
1665
|      Name    | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1666 1667 1668 1669 1670 1671 1672 1673 1674
| ------------- | ---------------------------------- | ---- | -------- |
| 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 已提交
1675
**System API**: This is a system API.
S
shawn_he 已提交
1676 1677 1678

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

S
shawn_he 已提交
1679
|      Name     | Type                                | Mandatory| Description    |
S
shawn_he 已提交
1680 1681 1682 1683 1684
| -------------- | ------------------------------------ | ---- | -------- |
| transactionId  | string                               | Yes  | Transaction ID.  |
| messageId      | string                               | Yes  | Message ID.  |
| date           | number                               | Yes  | Date.    |
| contentType    | string                               | Yes  | Content type.|
S
shawn_he 已提交
1685 1686 1687
| to             | Array<[MmsAddress](#mmsaddress8)\>   | Yes  | Destination address.  |
| version        | [MmsVersionType](#mmsversiontype8)   | Yes  | Version.    |
| from           | [MmsAddress](#mmsaddress8)           | No  | Source address.    |
S
shawn_he 已提交
1688 1689
| cc             | Array<[MmsAddress](#mmsaddress8)\>   | No  | Carbon copy.    |
| subject        | string                               | No  | Subject.    |
S
shawn_he 已提交
1690
| priority       | [MmsPriorityType](#mmsprioritytype8) | No  | Priority.  |
S
shawn_he 已提交
1691 1692 1693 1694 1695 1696 1697 1698 1699
| 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 已提交
1700
**System API**: This is a system API.
S
shawn_he 已提交
1701 1702 1703

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

S
shawn_he 已提交
1704
|    Name   | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1705 1706 1707
| ---------- | ---------------------------------- | ---- | -------- |
| version    | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
| messageId  | string                             | Yes  | Message ID.  |
S
shawn_he 已提交
1708 1709
| to         | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.  |
| from       | [MmsAddress](#mmsaddress8)         | Yes  | Source address.    |
S
shawn_he 已提交
1710 1711 1712
| date       | number                             | Yes  | Date.    |
| readStatus | number                             | Yes  | Read status.|

S
shawn_he 已提交
1713 1714 1715 1716
## MmsReadRecInd<sup>8+</sup>

Defines the MMS message reading index.

S
shawn_he 已提交
1717
**System API**: This is a system API.
S
shawn_he 已提交
1718 1719 1720

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

S
shawn_he 已提交
1721
|    Name   | Type                              | Mandatory| Description    |
S
shawn_he 已提交
1722
| ---------- | ---------------------------------- | ---- | -------- |
S
shawn_he 已提交
1723
| version    | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
S
shawn_he 已提交
1724
| messageId  | string                             | Yes  | Message ID.  |
S
shawn_he 已提交
1725 1726 1727
| to         | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.  |
| from       | [MmsAddress](#mmsaddress8)         | Yes  | Source address.    |
| readStatus | number                             | Yes  | Read status.|
S
shawn_he 已提交
1728 1729
| date       | number                             | No  | Date.    |

S
shawn_he 已提交
1730 1731 1732 1733
## MmsAttachment<sup>8+</sup>

Defines the attachment of an MMS message.

S
shawn_he 已提交
1734
**System API**: This is a system API.
S
shawn_he 已提交
1735 1736 1737

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

S
shawn_he 已提交
1738
|          Name          | Type                                | Mandatory| Description              |
S
shawn_he 已提交
1739 1740 1741 1742 1743 1744 1745 1746
| ----------------------- | ------------------------------------ | ---- | ------------------ |
| 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 已提交
1747
| inBuff                  | Array<number\>                       | No  | Whether the message is in the buffer.          |
S
shawn_he 已提交
1748 1749 1750 1751 1752 1753 1754
| fileName                | string                               | No  | File name.            |
| charset                 | [MmsCharSets](#mmscharsets8)         | No  | Character set.            |

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

Defines an MMSC address.

S
shawn_he 已提交
1755
**System API**: This is a system API.
S
shawn_he 已提交
1756 1757 1758

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

S
shawn_he 已提交
1759
|   Name | Type                        | Mandatory| Description  |
S
shawn_he 已提交
1760
| ------- | ---------------------------- | ---- | ------ |
S
shawn_he 已提交
1761
| address | string                       | Yes  | Network address.  |
S
shawn_he 已提交
1762 1763 1764 1765
| charset | [MmsCharSets](#mmscharsets8) | Yes  | Character set.|

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

S
shawn_he 已提交
1766
Message type.
S
shawn_he 已提交
1767

S
shawn_he 已提交
1768
**System API**: This is a system API.
S
shawn_he 已提交
1769 1770 1771

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

S
shawn_he 已提交
1772
|          Name            | Value  | Description                |
S
shawn_he 已提交
1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787
| ------------------------- | ---- | -------------------- |
| 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 已提交
1788
**System API**: This is a system API.
S
shawn_he 已提交
1789 1790 1791

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

S
shawn_he 已提交
1792
|    Name   | Value  | Description          |
S
shawn_he 已提交
1793 1794 1795 1796 1797 1798 1799 1800 1801
| ---------- | ---- | -------------- |
| 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 已提交
1802
**System API**: This is a system API.
S
shawn_he 已提交
1803 1804 1805

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

S
shawn_he 已提交
1806
|      Name      | Value  | Description       |
S
shawn_he 已提交
1807 1808 1809 1810 1811 1812 1813 1814 1815 1816
| --------------- | ---- | ----------- |
| 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 已提交
1817
**System API**: This is a system API.
S
shawn_he 已提交
1818 1819 1820

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

S
shawn_he 已提交
1821
|      Name      | Value    | Description               |
S
shawn_he 已提交
1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841
| --------------- | ------ | ------------------- |
| 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 已提交
1842
**System API**: This is a system API.
S
shawn_he 已提交
1843 1844 1845

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

S
shawn_he 已提交
1846
|    Name   | Value  | Description    |
S
shawn_he 已提交
1847 1848 1849 1850 1851 1852 1853 1854 1855
| ---------- | ---- | -------- |
| FROM_DATA  | 0    | Data source.|
| ATTACHMENT | 1    | Attachment.    |
| INLINE     | 2    | Inlining.    |

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

Enumerates report types.

S
shawn_he 已提交
1856
**System API**: This is a system API.
S
shawn_he 已提交
1857 1858 1859

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

S
shawn_he 已提交
1860
|  Name  | Value  | Description|
S
shawn_he 已提交
1861 1862 1863 1864
| ------- | ---- | ---- |
| MMS_YES | 128  | YES  |
| MMS_NO  | 129  | NO   |

S
shawn_he 已提交
1865
## CBConfigOptions<sup>7+</sup>
S
shawn_he 已提交
1866 1867 1868

Defines the cell broadcast configuration options.

S
shawn_he 已提交
1869
**System API**: This is a system API.
S
shawn_he 已提交
1870 1871 1872

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

S
shawn_he 已提交
1873
|      Name     | Type                | Mandatory| Description        |
S
shawn_he 已提交
1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884
| -------------- | -------------------- | ---- | ------------ |
| 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 已提交
1885
**System API**: This is a system API.
S
shawn_he 已提交
1886 1887 1888

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

S
shawn_he 已提交
1889
|           Name           | Value  | Description                       |
S
shawn_he 已提交
1890 1891 1892 1893 1894 1895 1896 1897 1898
| ------------------------- | ---- | --------------------------- |
| 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 已提交
1899
RAN type.
S
shawn_he 已提交
1900

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

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

S
shawn_he 已提交
1905
|   Name   | Value  | Description|
S
shawn_he 已提交
1906 1907 1908 1909 1910 1911 1912 1913
| --------- | ---- | ---- |
| TYPE_GSM  | 1    | GSM  |
| TYPE_CDMA | 2    | CMDA |

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

Enumerates SMS encoding schemes.

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

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

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

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

S
shawn_he 已提交
1933
|  Name | Type                                  | Mandatory| Description          |
S
shawn_he 已提交
1934 1935 1936 1937
| ------ | -------------------------------------- | ---- | -------------- |
| slotId | number                                 | Yes  | Card slot ID.        |
| smsc   | string                                 | Yes  | Short message service center.|
| pdu    | string                                 | Yes  | Protocol data unit.  |
S
shawn_he 已提交
1938
| status | [SimMessageStatus](#simmessagestatus7) | Yes  | Status.          |
S
shawn_he 已提交
1939 1940 1941 1942 1943

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

Defines the updating SIM message options.

S
shawn_he 已提交
1944
**System API**: This is a system API.
S
shawn_he 已提交
1945 1946 1947

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

S
shawn_he 已提交
1948
|   Name   | Type                                  | Mandatory| Description          |
S
shawn_he 已提交
1949 1950 1951 1952 1953 1954 1955
| --------- | -------------------------------------- | ---- | -------------- |
| 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 已提交
1956
## SimShortMessage<sup>7+</sup>
S
shawn_he 已提交
1957 1958 1959

Defines a SIM message.

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

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

S
shawn_he 已提交
1978
|    Name  | Type                              | Mandatory| Description  |
S
shawn_he 已提交
1979 1980 1981
| --------- | ---------------------------------- | ---- | ------ |
| messageId | string                             | Yes  | Message ID.|
| date      | number                             | Yes  | Date.  |
S
shawn_he 已提交
1982 1983
| to        | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.|
| status    | number                             | Yes  | Status  |
S
shawn_he 已提交
1984 1985 1986 1987 1988 1989
| version   | [MmsVersionType](#mmsversiontype8) | Yes  | Version.  |

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

Defines an MMS response index.

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
| ------------- | ---------------------------------- | ---- | -------- |
| transactionId | string                             | Yes  | Event ID.  |
S
shawn_he 已提交
1997
| status        | number                             | Yes  | Status    |
S
shawn_he 已提交
1998 1999 2000 2001 2002 2003 2004
| version       | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
| reportAllowed | [ReportType](#reporttype8)         | No  | Report allowed.|

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

Defines the SMS message segment information.

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

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

S
shawn_he 已提交
2009
|        Name         | Type                                    | Mandatory| Description        |
S
shawn_he 已提交
2010 2011 2012 2013 2014
| -------------------- | ---------------------------------------- | ---- | ------------ |
| splitCount           | number                                   | Yes  | Split count.    |
| encodeCount          | number                                   | Yes  | Encoding count.    |
| encodeCountRemaining | number                                   | Yes  | Remaining encoding count.|
| scheme               | [SmsEncodingScheme](#smsencodingscheme8) | Yes  | Encoding scheme.|