• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.telephony.sms (SMS)
2
3The **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.
4
5>**NOTE**
6>
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.
8
9## Modules to Import
10
11```ts
12import sms from '@ohos.telephony.sms';
13```
14
15## sms.createMessage
16
17createMessage\(pdu: Array&lt;number&gt;, specification: string, callback: AsyncCallback\<ShortMessage\>\): void
18
19Creates an SMS instance based on the protocol data unit (PDU) and specified SMS protocol. This API uses an asynchronous callback to return the result.
20
21**System capability**: SystemCapability.Telephony.SmsMms
22
23**Parameters**
24
25| Name       | Type                                              | Mandatory| Description                                                        |
26| ------------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
27| pdu           | Array&lt;number&gt;                                | Yes  | Protocol data unit, which is obtained from the received SMS message.                          |
28| specification | string                                             | Yes  | SMS protocol type. <br>- **3gpp**: GSM/UMTS/LTE SMS<br>- **3gpp2**: CDMA SMS|
29| callback      | AsyncCallback&lt;[ShortMessage](#shortmessage)&gt; | Yes  | Callback used to return the result. |
30
31**Error codes**
32
33For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
34
35| ID|                  Error Message                    |
36| -------- | -------------------------------------------- |
37| 401      | Parameter error.                             |
38| 8300001  | Invalid parameter value.                     |
39| 8300002  | Operation failed. Cannot connect to service. |
40| 8300003  | System internal error.                       |
41| 8300999  | Unknown error code.                          |
42
43**Example**
44
45```ts
46import sms from '@ohos.telephony.sms';
47import { BusinessError } from '@ohos.base';
48
49const specification: string = '3gpp';
50// Display PDUs in array format. The type is number.
51const pdu: Array<number> = [0x01, 0x00, 0x05, 0x81, 0x01, 0x80, 0xF6, 0x00, 0x00, 0x05, 0xE8, 0x32, 0x9B, 0xFD, 0x06];
52sms.createMessage(pdu, specification, (err: BusinessError, data: sms.ShortMessage) => {
53    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
54});
55```
56
57
58## sms.createMessage
59
60createMessage\(pdu: Array&lt;number&gt;, specification: string\): Promise\<ShortMessage\>
61
62Creates an SMS instance based on the PDU and specified SMS protocol. This API uses a promise to return the result.
63
64**System capability**: SystemCapability.Telephony.SmsMms
65
66**Parameters**
67
68| Name       | Type               | Mandatory| Description                                                        |
69| ------------- | ------------------- | ---- | ------------------------------------------------------------ |
70| pdu           | Array&lt;number&gt; | Yes  | Protocol data unit, which is obtained from the received SMS message.                          |
71| specification | string              | Yes  | SMS protocol type. <br>- **3gpp**: GSM/UMTS/LTE SMS<br>- **3gpp2**: CDMA SMS|
72
73**Return value**
74
75| Type                                        | Description                             |
76| -------------------------------------------- | --------------------------------- |
77| Promise&lt;[ShortMessage](#shortmessage)&gt; | Promise used to return the result.|
78
79**Error codes**
80
81For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
82
83| ID|                  Error Message                    |
84| -------- | -------------------------------------------- |
85| 401      | Parameter error.                             |
86| 8300001  | Invalid parameter value.                     |
87| 8300002  | Operation failed. Cannot connect to service. |
88| 8300003  | System internal error.                       |
89| 8300999  | Unknown error code.                          |
90
91**Example**
92
93```ts
94import sms from '@ohos.telephony.sms';
95import { BusinessError } from '@ohos.base';
96
97const specification: string = '3gpp';
98// Display PDUs in array format. The type is number.
99const pdu: Array<number> = [0x01, 0x00, 0x05, 0x81, 0x01, 0x80, 0xF6, 0x00, 0x00, 0x05, 0xE8, 0x32, 0x9B, 0xFD, 0x06];
100sms.createMessage(pdu, specification).then((data: sms.ShortMessage) => {
101    console.log(`createMessage success, promise: data->${JSON.stringify(data)}`);
102}).catch((err: BusinessError) => {
103    console.error(`createMessage failed, promise: err->${JSON.stringify(err)}`);
104});
105```
106
107## sms.sendMessage<sup>(deprecated)</sup>
108
109sendMessage\(options: SendMessageOptions\): void
110
111Sends an SMS message.
112
113> **NOTE**
114>
115> This API is supported since API version 6 and deprecated since API version 10. You are advised to use [sendShortMessage](#smssendshortmessage10).
116
117**Required permissions**: ohos.permission.SEND_MESSAGES
118
119**System capability**: SystemCapability.Telephony.SmsMms
120
121**Parameters**
122
123| Name | Type                                     | Mandatory| Description                                                        |
124| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
125| options | [SendMessageOptions](#sendmessageoptions) | Yes  | Options (including the callback) for sending SMS messages. For details, see [SendMessageOptions](#sendmessageoptions).|
126
127**Error codes**
128
129For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
130
131| ID|                 Error Message                    |
132| -------- | -------------------------------------------- |
133| 201      | Permission denied.                           |
134| 401      | Parameter error.                             |
135| 8300001  | Invalid parameter value.                     |
136| 8300002  | Operation failed. Cannot connect to service. |
137| 8300003  | System internal error.                       |
138| 8300999  | Unknown error code.                          |
139
140**Example**
141
142```ts
143import sms from '@ohos.telephony.sms';
144import { AsyncCallback } from '@ohos.base';
145import { BusinessError } from '@ohos.base';
146
147let sendCallback: AsyncCallback<sms.ISendShortMessageCallback> = (err: BusinessError, data: sms.ISendShortMessageCallback[]) => {
148    console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
149};
150let deliveryCallback: AsyncCallback<sms.IDeliveryShortMessageCallback> = (err: BusinessError, data: sms.IDeliveryShortMessageCallback) => {
151    console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
152};
153let options: sms.SendMessageOptions = {
154    slotId: 0,
155    content: 'SMS message content';
156    destinationHost: '+861xxxxxxxxxx',
157    serviceCenter: '+861xxxxxxxxxx',
158    destinationPort: 1000,
159    sendCallback: sendCallback,
160    deliveryCallback: deliveryCallback
161};
162sms.sendMessage(options);
163```
164
165## sms.sendShortMessage<sup>10+</sup>
166
167sendShortMessage\(options: SendMessageOptions, callback: AsyncCallback&lt;void&gt;\): void
168
169Sends an SMS message. This API uses an asynchronous callback to return the result.
170
171**Required permissions**: ohos.permission.SEND_MESSAGES
172
173**System capability**: SystemCapability.Telephony.SmsMms
174
175**Parameters**
176
177| Name  | Type                       | Mandatory| Description                                    |
178| -------- | --------------------------- | ---- | ---------------------------------------- |
179| options | [SendMessageOptions](#sendmessageoptions) | Yes  | Options (including the callback) for sending SMS messages. For details, see [SendMessageOptions](#sendmessageoptions).|
180| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
181
182**Error codes**
183
184For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
185
186| ID|                 Error Message                    |
187| -------- | -------------------------------------------- |
188| 201      | Permission denied.                           |
189| 401      | Parameter error.                             |
190| 8300001  | Invalid parameter value.                     |
191| 8300002  | Operation failed. Cannot connect to service. |
192| 8300003  | System internal error.                       |
193| 8300999  | Unknown error code.                          |
194
195**Example**
196
197```ts
198import sms from '@ohos.telephony.sms';
199import { AsyncCallback } from '@ohos.base';
200import { BusinessError } from '@ohos.base';
201
202let sendCallback: AsyncCallback<sms.ISendShortMessageCallback> = (err: BusinessError, data: sms.ISendShortMessageCallback) => {
203    console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
204};
205let deliveryCallback: AsyncCallback<sms.IDeliveryShortMessageCallback> = (err: BusinessError, data: sms.IDeliveryShortMessageCallback) => {
206    console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
207};
208let options: sms.SendMessageOptions = {
209    slotId: 0,
210    content: 'SMS message content';
211    destinationHost: '+861xxxxxxxxxx',
212    serviceCenter: '+861xxxxxxxxxx',
213    destinationPort: 1000,
214    sendCallback: sendCallback,
215    deliveryCallback: deliveryCallback
216};
217sms.sendShortMessage(options, (err: BusinessError) => {
218    console.log(`callback: err->${JSON.stringify(err)}`);
219});
220```
221
222## sms.sendShortMessage<sup>10+</sup>
223
224sendShortMessage\(options: SendMessageOptions\): Promise&lt;void&gt;
225
226Sends an SMS message. This API uses a promise to return the result.
227
228**Required permissions**: ohos.permission.SEND_MESSAGES
229
230**System capability**: SystemCapability.Telephony.SmsMms
231
232**Parameters**
233
234| Name  | Type                       | Mandatory| Description                                    |
235| -------- | --------------------------- | ---- | ---------------------------------------- |
236| options | [SendMessageOptions](#sendmessageoptions) | Yes  | Options (including the callback) for sending SMS messages. For details, see [SendMessageOptions](#sendmessageoptions).|
237
238**Return value**
239
240| Type           | Description                                                        |
241| --------------- | ------------------------------------------------------------ |
242| Promise&lt;void&gt; | Promise used to return the result.|
243
244**Error codes**
245
246For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
247
248| ID|                 Error Message                    |
249| -------- | -------------------------------------------- |
250| 201      | Permission denied.                           |
251| 401      | Parameter error.                             |
252| 8300001  | Invalid parameter value.                     |
253| 8300002  | Operation failed. Cannot connect to service. |
254| 8300003  | System internal error.                       |
255| 8300999  | Unknown error code.                          |
256
257**Example**
258
259```ts
260import sms from '@ohos.telephony.sms';
261import { AsyncCallback } from '@ohos.base';
262import { BusinessError } from '@ohos.base';
263
264let sendCallback: AsyncCallback<sms.ISendShortMessageCallback> = (err: BusinessError, data: sms.ISendShortMessageCallback) => {
265    console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
266};
267let deliveryCallback: AsyncCallback<sms.IDeliveryShortMessageCallback> = (err: BusinessError, data: sms.IDeliveryShortMessageCallback) => {
268    console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
269};
270let options: sms.SendMessageOptions = {
271    slotId: 0,
272    content: 'SMS message content';
273    destinationHost: '+861xxxxxxxxxx',
274    serviceCenter: '+861xxxxxxxxxx',
275    destinationPort: 1000,
276    sendCallback: sendCallback,
277    deliveryCallback: deliveryCallback
278};
279let promise = sms.sendShortMessage(options);
280promise.then(() => {
281    console.log(`sendShortMessage success`);
282}).catch((err: BusinessError) => {
283    console.error(`sendShortMessage failed, promise: err->${JSON.stringify(err)}`);
284});
285
286```
287
288## sms.getDefaultSmsSlotId<sup>7+</sup>
289
290getDefaultSmsSlotId\(callback: AsyncCallback&lt;number&gt;\): void
291
292Obtains the default slot ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
293
294**System capability**: SystemCapability.Telephony.SmsMms
295
296**Parameters**
297
298| Name  | Type                       | Mandatory| Description                                    |
299| -------- | --------------------------- | ---- | ---------------------------------------- |
300| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
301
302**Example**
303
304```ts
305import sms from '@ohos.telephony.sms';
306import { BusinessError } from '@ohos.base';
307
308sms.getDefaultSmsSlotId((err: BusinessError, data: number) => {
309    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
310});
311```
312
313
314## sms.getDefaultSmsSlotId<sup>7+</sup>
315
316getDefaultSmsSlotId\(\): Promise&lt;number&gt;
317
318Obtains the default slot ID of the SIM card used to send SMS messages. This API uses a promise to return the result.
319
320**System capability**: SystemCapability.Telephony.SmsMms
321
322**Return value**
323
324| Type           | Description                                                        |
325| --------------- | ------------------------------------------------------------ |
326| Promise&lt;number&gt; | Promise used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
327
328**Example**
329
330```ts
331import sms from '@ohos.telephony.sms';
332import { BusinessError } from '@ohos.base';
333
334sms.getDefaultSmsSlotId().then((data: number) => {
335    console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
336}).catch((err: BusinessError) => {
337    console.error(`getDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
338});
339```
340
341## sms.setDefaultSmsSlotId<sup>7+</sup>
342
343setDefaultSmsSlotId\(slotId: number, callback: AsyncCallback&lt;void&gt;\): void
344
345Sets the default slot ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
346
347**System API**: This is a system API.
348
349**Required permissions**: ohos.permission.SET_TELEPHONY_STATE
350
351**System capability**: SystemCapability.Telephony.SmsMms
352
353**Parameters**
354
355| Name  | Type                     | Mandatory| Description                                                        |
356| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
357| slotId   | number                    | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
358| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. |
359
360**Error codes**
361
362For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
363
364| ID|                 Error Message                    |
365| -------- | -------------------------------------------- |
366| 201      | Permission denied.                           |
367| 202      | Non-system applications use system APIs.     |
368| 401      | Parameter error.                             |
369| 8300001  | Invalid parameter value.                     |
370| 8300002  | Operation failed. Cannot connect to service. |
371| 8300003  | System internal error.                       |
372| 8300004  | Do not have sim card.                        |
373| 8300999  | Unknown error code.                          |
374
375**Example**
376
377```ts
378import sms from '@ohos.telephony.sms';
379import { BusinessError } from '@ohos.base';
380
381sms.setDefaultSmsSlotId(0, (err: BusinessError) => {
382    console.log(`callback: err->${JSON.stringify(err)}.`);
383});
384```
385
386
387## sms.setDefaultSmsSlotId<sup>7+</sup>
388
389setDefaultSmsSlotId\(slotId: number\): Promise&lt;void&gt;
390
391Sets the default slot ID of the SIM card used to send SMS messages. This API uses a promise to return the result.
392
393**System API**: This is a system API.
394
395**Required permissions**: ohos.permission.SET_TELEPHONY_STATE
396
397**System capability**: SystemCapability.Telephony.SmsMms
398
399**Parameters**
400
401| Name| Type  | Mandatory| Description                                                        |
402| ------ | ------ | ---- | ------------------------------------------------------------ |
403| slotId | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
404
405**Return value**
406
407| Type           | Description                           |
408| --------------- | ------------------------------- |
409| Promise\<void\> | Promise used to return the result.|
410
411**Error codes**
412
413For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
414
415| ID|                 Error Message                    |
416| -------- | -------------------------------------------- |
417| 201      | Permission denied.                           |
418| 202      | Non-system applications use system APIs.     |
419| 401      | Parameter error.                             |
420| 8300001  | Invalid parameter value.                     |
421| 8300002  | Operation failed. Cannot connect to service. |
422| 8300003  | System internal error.                       |
423| 8300004  | Do not have sim card.                        |
424| 8300999  | Unknown error code.                          |
425
426**Example**
427
428```ts
429import sms from '@ohos.telephony.sms';
430import { BusinessError } from '@ohos.base';
431
432sms.setDefaultSmsSlotId(0).then(() => {
433    console.log(`setDefaultSmsSlotId success.`);
434}).catch((err: BusinessError) => {
435    console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
436});
437```
438
439## sms.setSmscAddr<sup>7+</sup>
440
441setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback\<void\>\): void
442
443Sets the short message service center (SMSC) address. This API uses an asynchronous callback to return the result.
444
445**System API**: This is a system API.
446
447**Required permissions**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
448
449**System capability**: SystemCapability.Telephony.SmsMms
450
451**Parameters**
452
453| Name  | Type                     | Mandatory| Description                                     |
454| -------- | ------------------------- | ---- | ----------------------------------------- |
455| slotId   | number                    | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
456| smscAddr | string                    | Yes  | SMSC address.                       |
457| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                               |
458
459**Error codes**
460
461For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
462
463| ID|                  Error Message                   |
464| -------- | -------------------------------------------- |
465| 201      | Permission denied.                           |
466| 202      | Non-system applications use system APIs.     |
467| 401      | Parameter error.                             |
468| 8300001  | Invalid parameter value.                     |
469| 8300002  | Operation failed. Cannot connect to service. |
470| 8300003  | System internal error.                       |
471| 8300999  | Unknown error code.                          |
472
473**Example**
474
475```ts
476import sms from '@ohos.telephony.sms';
477import { BusinessError } from '@ohos.base';
478
479let slotId: number = 0;
480let smscAddr: string = '+861xxxxxxxxxx';
481sms.setSmscAddr(slotId, smscAddr, (err: BusinessError) => {
482      console.log(`callback: err->${JSON.stringify(err)}`);
483});
484```
485
486
487## sms.setSmscAddr<sup>7+</sup>
488
489setSmscAddr\(slotId: number, smscAddr: string\): Promise\<void\>
490
491Sets the SMSC address. This API uses a promise to return the result.
492
493**System API**: This is a system API.
494
495**Required permissions**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
496
497**System capability**: SystemCapability.Telephony.SmsMms
498
499**Parameters**
500
501| Name  | Type  | Mandatory| Description                                     |
502| -------- | ------ | ---- | ----------------------------------------- |
503| slotId   | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
504| smscAddr | string | Yes  | SMSC address.                       |
505
506**Return value**
507
508| Type               | Description                           |
509| ------------------- | ------------------------------- |
510| Promise&lt;void&gt; | Promise used to return the result.|
511
512**Error codes**
513
514For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
515
516| ID|                  Error Message                   |
517| -------- | -------------------------------------------- |
518| 201      | Permission denied.                           |
519| 202      | Non-system applications use system APIs.     |
520| 401      | Parameter error.                             |
521| 8300001  | Invalid parameter value.                     |
522| 8300002  | Operation failed. Cannot connect to service. |
523| 8300003  | System internal error.                       |
524| 8300999  | Unknown error code.                          |
525
526**Example**
527
528```ts
529import sms from '@ohos.telephony.sms';
530import { BusinessError } from '@ohos.base';
531
532let slotId: number = 0;
533let smscAddr: string = '+861xxxxxxxxxx';
534sms.setSmscAddr(slotId, smscAddr).then(() => {
535    console.log(`setSmscAddr success.`);
536}).catch((err: BusinessError) => {
537    console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`);
538});
539```
540
541
542## sms.getSmscAddr<sup>7+</sup>
543
544getSmscAddr\(slotId: number, callback: AsyncCallback\<string\>\): void
545
546Obtains the SMSC address. This API uses an asynchronous callback to return the result.
547
548**System API**: This is a system API.
549
550**Required permissions**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
551
552**System capability**: SystemCapability.Telephony.SmsMms
553
554**Parameters**
555
556| Name  | Type                       | Mandatory| Description                                     |
557| -------- | --------------------------- | ---- | ----------------------------------------- |
558| slotId   | number                      | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
559| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.                               |
560
561**Error codes**
562
563For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
564
565| ID|                  Error Message                   |
566| -------- | -------------------------------------------- |
567| 201      | Permission denied.                           |
568| 202      | Non-system applications use system APIs.     |
569| 401      | Parameter error.                             |
570| 8300001  | Invalid parameter value.                     |
571| 8300002  | Operation failed. Cannot connect to service. |
572| 8300003  | System internal error.                       |
573| 8300999  | Unknown error code.                          |
574
575**Example**
576
577```ts
578import sms from '@ohos.telephony.sms';
579import { BusinessError } from '@ohos.base';
580
581let slotId: number = 0;
582sms.getSmscAddr(slotId, (err: BusinessError, data: string) => {
583      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
584});
585```
586
587
588## sms.getSmscAddr<sup>7+</sup>
589
590getSmscAddr\(slotId: number\): Promise\<string\>
591
592Obtains the SMSC address. This API uses a promise to return the result.
593
594**System API**: This is a system API.
595
596**Required permissions**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
597
598**System capability**: SystemCapability.Telephony.SmsMms
599
600**Parameters**
601
602| Name| Type  | Mandatory| Description                                     |
603| ------ | ------ | ---- | ----------------------------------------- |
604| slotId | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
605
606**Return value**
607
608| Type                 | Description                                         |
609| --------------------- | --------------------------------------------- |
610| Promise&lt;string&gt; | Promise used to return the result.|
611
612**Error codes**
613
614For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
615
616| ID|                  Error Message                   |
617| -------- | -------------------------------------------- |
618| 201      | Permission denied.                           |
619| 202      | Non-system applications use system APIs.     |
620| 401      | Parameter error.                             |
621| 8300001  | Invalid parameter value.                     |
622| 8300002  | Operation failed. Cannot connect to service. |
623| 8300003  | System internal error.                       |
624| 8300999  | Unknown error code.                          |
625
626**Example**
627
628```ts
629import sms from '@ohos.telephony.sms';
630import { BusinessError } from '@ohos.base';
631
632let slotId: number = 0;
633sms.getSmscAddr(slotId).then((data: string) => {
634    console.log(`getSmscAddr success, promise: data->${JSON.stringify(data)}`);
635}).catch((err: BusinessError) => {
636    console.error(`getSmscAddr failed, promise: err->${JSON.stringify(err)}`);
637});
638```
639
640## sms.hasSmsCapability<sup>7+</sup>
641
642hasSmsCapability\(\): boolean
643
644Checks whether the current device can send and receive SMS messages. This API works in synchronous mode.
645
646**System capability**: SystemCapability.Telephony.SmsMms
647
648**Return value**
649
650| Type   | Description                                                        |
651| ------- | ------------------------------------------------------------ |
652| boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.|
653
654```ts
655import sms from '@ohos.telephony.sms';
656
657let result = sms.hasSmsCapability();
658console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
659```
660
661## sms.splitMessage<sup>8+</sup>
662
663splitMessage\(content: string, callback: AsyncCallback\<Array\<string\>\>\): void
664
665Splits an SMS message into multiple segments. This API uses an asynchronous callback to return the result.
666
667**System API**: This is a system API.
668
669**Required permissions**: ohos.permission.SEND_MESSAGES
670
671**System capability**: SystemCapability.Telephony.SmsMms
672
673**Parameters**
674
675| Name  | Type                         | Mandatory| Description                         |
676| -------- | ----------------------------- | ---- | ----------------------------- |
677| content  | string                        | Yes  | SMS message content. The value cannot be null.|
678| callback | AsyncCallback<Array<string\>> | Yes  | Callback used to return the result.                   |
679
680**Error codes**
681
682For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
683
684| ID|                  Error Message                   |
685| -------- | -------------------------------------------- |
686| 201      | Permission denied.                           |
687| 202      | Non-system applications use system APIs.     |
688| 401      | Parameter error.                             |
689| 8300001  | Invalid parameter value.                     |
690| 8300002  | Operation failed. Cannot connect to service. |
691| 8300003  | System internal error.                       |
692| 8300999  | Unknown error code.                          |
693
694**Example**
695
696```ts
697import sms from '@ohos.telephony.sms';
698import { BusinessError } from '@ohos.base';
699
700let content: string = "long message";
701sms.splitMessage(content, (err: BusinessError, data: string[]) => {
702      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
703});
704```
705
706
707## sms.splitMessage<sup>8+</sup>
708
709splitMessage\(content: string\): Promise\<Array\<string\>\>
710
711Splits an SMS message into multiple segments. This API uses a promise to return the result.
712
713**System API**: This is a system API.
714
715**Required permissions**: ohos.permission.SEND_MESSAGES
716
717**System capability**: SystemCapability.Telephony.SmsMms
718
719**Parameters**
720
721| Name | Type  | Mandatory| Description                        |
722| ------- | ------ | ---- | ---------------------------- |
723| content | string | Yes  | SMS message content. The value cannot be null.|
724
725**Return value**
726
727| Type                   | Description                               |
728| ----------------------- | ----------------------------------- |
729| Promise<Array<string\>> | Promise used to return the result.|
730
731**Error codes**
732
733For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
734
735| ID|                  Error Message                   |
736| -------- | -------------------------------------------- |
737| 201      | Permission denied.                           |
738| 202      | Non-system applications use system APIs.     |
739| 401      | Parameter error.                             |
740| 8300001  | Invalid parameter value.                     |
741| 8300002  | Operation failed. Cannot connect to service. |
742| 8300003  | System internal error.                       |
743| 8300999  | Unknown error code.                          |
744
745**Example**
746
747```ts
748import sms from '@ohos.telephony.sms';
749import { BusinessError } from '@ohos.base';
750
751let content: string = "long message";
752let promise = sms.splitMessage(content);
753promise.then((data: string[]) => {
754    console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`);
755}).catch((err: BusinessError) => {
756    console.error(`splitMessage failed, promise: err->${JSON.stringify(err)}`);
757});
758```
759
760## sms.addSimMessage<sup>7+</sup>
761
762addSimMessage\(options: SimMessageOptions, callback: AsyncCallback\<void\>\): void
763
764Adds a message to the SIM card. If the SIM card is full, an error is reported. This API uses an asynchronous callback to return the result.
765
766**System API**: This is a system API.
767
768**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
769
770**System capability**: SystemCapability.Telephony.SmsMms
771
772**Parameters**
773
774| Name  | Type                                    | Mandatory| Description           |
775| -------- | ---------------------------------------- | ---- | --------------- |
776| options  | [SimMessageOptions](#simmessageoptions7) | Yes  | SIM message options.|
777| callback | AsyncCallback&lt;void&gt;                | Yes  | Callback used to return the result.     |
778
779**Error codes**
780
781For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
782
783| ID|                  Error Message                   |
784| -------- | -------------------------------------------- |
785| 201      | Permission denied.                           |
786| 202      | Non-system applications use system APIs.     |
787| 401      | Parameter error.                             |
788| 8300001  | Invalid parameter value.                     |
789| 8300002  | Operation failed. Cannot connect to service. |
790| 8300003  | System internal error.                       |
791| 8300999  | Unknown error code.                          |
792
793**Example**
794
795```ts
796import sms from '@ohos.telephony.sms';
797import { BusinessError } from '@ohos.base';
798
799let simMessageOptions: sms.SimMessageOptions = {
800    slotId: 0,
801    smsc: "test",
802    pdu: "xxxxxx",
803    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
804};
805sms.addSimMessage(simMessageOptions, (err: BusinessError) => {
806      console.log(`callback: err->${JSON.stringify(err)}`);
807});
808```
809
810
811## sms.addSimMessage<sup>7+</sup>
812
813addSimMessage\(options: SimMessageOptions\): Promise\<void\>
814
815Adds a message to the SIM card. If the SIM card is full, an error is reported. This API uses a promise to return the result.
816
817**System API**: This is a system API.
818
819**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
820
821**System capability**: SystemCapability.Telephony.SmsMms
822
823**Parameters**
824
825| Name | Type                                    | Mandatory| Description           |
826| ------- | ---------------------------------------- | ---- | --------------- |
827| options | [SimMessageOptions](#simmessageoptions7) | Yes  | SIM message options.|
828
829**Return value**
830
831| Type               | Description                         |
832| ------------------- | ----------------------------- |
833| Promise&lt;void&gt; |  Promise used to return the result.|
834
835**Error codes**
836
837For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
838
839| ID|                  Error Message                   |
840| -------- | -------------------------------------------- |
841| 201      | Permission denied.                           |
842| 202      | Non-system applications use system APIs.     |
843| 401      | Parameter error.                             |
844| 8300001  | Invalid parameter value.                     |
845| 8300002  | Operation failed. Cannot connect to service. |
846| 8300003  | System internal error.                       |
847| 8300999  | Unknown error code.                          |
848
849**Example**
850
851```ts
852import sms from '@ohos.telephony.sms';
853import { BusinessError } from '@ohos.base';
854
855let simMessageOptions: sms.SimMessageOptions = {
856    slotId: 0,
857    smsc: "test",
858    pdu: "xxxxxx",
859    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
860};
861sms.addSimMessage(simMessageOptions).then(() => {
862    console.log(`addSimMessage success.`);
863}).catch((err: BusinessError) => {
864    console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`);
865});
866```
867
868## sms.delSimMessage<sup>7+</sup>
869
870delSimMessage\(slotId: number, msgIndex: number, callback: AsyncCallback\<void\>\): void
871
872Deletes a message from the SIM card. If the specified **msgIndex** is invalid, an error is reported. This API uses an asynchronous callback to return the result.
873
874**System API**: This is a system API.
875
876**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
877
878**System capability**: SystemCapability.Telephony.SmsMms
879
880**Parameters**
881
882| Name  | Type                     | Mandatory| Description                                     |
883| -------- | ------------------------- | ---- | ----------------------------------------- |
884| slotId   | number                    | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
885| msgIndex | number                    | Yes  | Message index.                                 |
886| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                               |
887
888**Error codes**
889
890For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
891
892| ID|                  Error Message                   |
893| -------- | -------------------------------------------- |
894| 201      | Permission denied.                           |
895| 202      | Non-system applications use system APIs.     |
896| 401      | Parameter error.                             |
897| 8300001  | Invalid parameter value.                     |
898| 8300002  | Operation failed. Cannot connect to service. |
899| 8300003  | System internal error.                       |
900| 8300999  | Unknown error code.                          |
901
902**Example**
903
904```ts
905import sms from '@ohos.telephony.sms';
906import { BusinessError } from '@ohos.base';
907
908let slotId: number = 0;
909let msgIndex: number = 1;
910sms.delSimMessage(slotId, msgIndex, (err: BusinessError) => {
911      console.log(`callback: err->${JSON.stringify(err)}`);
912});
913```
914
915
916## sms.delSimMessage<sup>7+</sup>
917
918delSimMessage\(slotId: number, msgIndex: number\): Promise\<void\>
919
920Deletes a message from the SIM card. If the specified **msgIndex** is invalid, an error is reported. This API uses a promise to return the result.
921
922**System API**: This is a system API.
923
924**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
925
926**System capability**: SystemCapability.Telephony.SmsMms
927
928**Parameters**
929
930| Name  | Type  | Mandatory| Description                                     |
931| -------- | ------ | ---- | ----------------------------------------- |
932| slotId   | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
933| msgIndex | number | Yes  | Message index.                                 |
934
935**Return value**
936
937| Type               | Description                         |
938| ------------------- | ----------------------------- |
939| Promise&lt;void&gt; |  Promise used to return the result.|
940
941**Error codes**
942
943For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
944
945| ID|                  Error Message                   |
946| -------- | -------------------------------------------- |
947| 201      | Permission denied.                           |
948| 202      | Non-system applications use system APIs.     |
949| 401      | Parameter error.                             |
950| 8300001  | Invalid parameter value.                     |
951| 8300002  | Operation failed. Cannot connect to service. |
952| 8300003  | System internal error.                       |
953| 8300999  | Unknown error code.                          |
954
955**Example**
956
957```ts
958import sms from '@ohos.telephony.sms';
959import { BusinessError } from '@ohos.base';
960
961let slotId: number = 0;
962let msgIndex: number = 1;
963let promise = sms.delSimMessage(slotId, msgIndex);
964promise.then(() => {
965    console.log(`delSimMessage success.`);
966}).catch((err: BusinessError) => {
967    console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`);
968});
969```
970
971## sms.updateSimMessage<sup>7+</sup>
972
973updateSimMessage\(options: UpdateSimMessageOptions, callback: AsyncCallback\<void\>\): void
974
975Updates a SIM message. This API uses an asynchronous callback to return the result.
976
977**System API**: This is a system API.
978
979**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
980
981**System capability**: SystemCapability.Telephony.SmsMms
982
983**Parameters**
984
985| Name  | Type                                                | Mandatory| Description               |
986| -------- | ---------------------------------------------------- | ---- | ------------------- |
987| options  | [UpdateSimMessageOptions](#updatesimmessageoptions7) | Yes  | SIM message updating options.|
988| callback | AsyncCallback&lt;void&gt;                            | Yes  | Callback used to return the result.         |
989
990**Error codes**
991
992For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
993
994| ID|                  Error Message                   |
995| -------- | -------------------------------------------- |
996| 201      | Permission denied.                           |
997| 202      | Non-system applications use system APIs.     |
998| 401      | Parameter error.                             |
999| 8300001  | Invalid parameter value.                     |
1000| 8300002  | Operation failed. Cannot connect to service. |
1001| 8300003  | System internal error.                       |
1002| 8300999  | Unknown error code.                          |
1003
1004**Example**
1005
1006```ts
1007import sms from '@ohos.telephony.sms';
1008import { BusinessError } from '@ohos.base';
1009
1010let updateSimMessageOptions: sms.UpdateSimMessageOptions = {
1011    slotId: 0,
1012    msgIndex: 1,
1013    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
1014    pdu: "xxxxxxx",
1015    smsc: "test"
1016};
1017sms.updateSimMessage(updateSimMessageOptions, (err: BusinessError) => {
1018      console.log(`callback: err->${JSON.stringify(err)}`);
1019});
1020```
1021
1022
1023## sms.updateSimMessage<sup>7+</sup>
1024
1025updateSimMessage\(options: UpdateSimMessageOptions\): Promise\<void\>
1026
1027Updates a SIM message. This API uses a promise to return the result.
1028
1029**System API**: This is a system API.
1030
1031**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES
1032
1033**System capability**: SystemCapability.Telephony.SmsMms
1034
1035**Parameters**
1036
1037| Name | Type                                                | Mandatory| Description               |
1038| ------- | ---------------------------------------------------- | ---- | ------------------- |
1039| options | [UpdateSimMessageOptions](#updatesimmessageoptions7) | Yes  | SIM message updating options.|
1040
1041**Return value**
1042
1043| Type               | Description                         |
1044| ------------------- | ----------------------------- |
1045| Promise&lt;void&gt; | Promise used to return the result.|
1046
1047**Error codes**
1048
1049For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1050
1051| ID|                  Error Message                   |
1052| -------- | -------------------------------------------- |
1053| 201      | Permission denied.                           |
1054| 202      | Non-system applications use system APIs.     |
1055| 401      | Parameter error.                             |
1056| 8300001  | Invalid parameter value.                     |
1057| 8300002  | Operation failed. Cannot connect to service. |
1058| 8300003  | System internal error.                       |
1059| 8300999  | Unknown error code.                          |
1060
1061**Example**
1062
1063```ts
1064import sms from '@ohos.telephony.sms';
1065import { BusinessError } from '@ohos.base';
1066
1067let updateSimMessageOptions: sms.UpdateSimMessageOptions = {
1068    slotId: 0,
1069    msgIndex: 1,
1070    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
1071    pdu: "xxxxxxx",
1072    smsc: "test"
1073};
1074let promise = sms.updateSimMessage(updateSimMessageOptions);
1075promise.then(() => {
1076    console.log(`updateSimMessage success.`);
1077}).catch((err: BusinessError) => {
1078    console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`);
1079});
1080```
1081
1082## sms.getAllSimMessages<sup>7+</sup>
1083
1084getAllSimMessages\(slotId: number, callback: AsyncCallback\<Array\<SimShortMessage\>\>\): void
1085
1086Obtains all SIM card messages. This API uses an asynchronous callback to return the result.
1087
1088**System API**: This is a system API.
1089
1090**Required permissions**: ohos.permission.RECEIVE_SMS
1091
1092**System capability**: SystemCapability.Telephony.SmsMms
1093
1094**Parameters**
1095
1096| Name  | Type                                                       | Mandatory| Description                                     |
1097| -------- | ----------------------------------------------------------- | ---- | ----------------------------------------- |
1098| slotId   | number                                                      | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
1099| callback | AsyncCallback<Array<[SimShortMessage](#simshortmessage7)\>> | Yes  | Callback used to return the result.                               |
1100
1101**Error codes**
1102
1103For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1104
1105| ID|                  Error Message                   |
1106| -------- | -------------------------------------------- |
1107| 201      | Permission denied.                           |
1108| 202      | Non-system applications use system APIs.     |
1109| 401      | Parameter error.                             |
1110| 8300001  | Invalid parameter value.                     |
1111| 8300002  | Operation failed. Cannot connect to service. |
1112| 8300003  | System internal error.                       |
1113| 8300999  | Unknown error code.                          |
1114
1115**Example**
1116
1117```ts
1118import sms from '@ohos.telephony.sms';
1119import { BusinessError } from '@ohos.base';
1120
1121let slotId: number = 0;
1122sms.getAllSimMessages(slotId, (err: BusinessError, data: sms.SimShortMessage[]) => {
1123      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1124});
1125```
1126
1127
1128## sms.getAllSimMessages<sup>7+</sup>
1129
1130getAllSimMessages\(slotId: number\): Promise\<Array\<SimShortMessage\>\>
1131
1132Obtains all SIM card messages. This API uses a promise to return the result.
1133
1134**System API**: This is a system API.
1135
1136**Required permissions**: ohos.permission.RECEIVE_SMS
1137
1138**System capability**: SystemCapability.Telephony.SmsMms
1139
1140**Parameters**
1141
1142| Name| Type  | Mandatory| Description                                     |
1143| ------ | ------ | ---- | ----------------------------------------- |
1144| slotId | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
1145
1146**Return value**
1147
1148| Type                                                   | Description                              |
1149| ------------------------------------------------------- | ---------------------------------- |
1150| Promise<Array<[SimShortMessage](#simshortmessage7)\>&gt; | Promise used to return the result.|
1151
1152**Error codes**
1153
1154For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1155
1156| ID|                  Error Message                   |
1157| -------- | -------------------------------------------- |
1158| 201      | Permission denied.                           |
1159| 202      | Non-system applications use system APIs.     |
1160| 401      | Parameter error.                             |
1161| 8300001  | Invalid parameter value.                     |
1162| 8300002  | Operation failed. Cannot connect to service. |
1163| 8300003  | System internal error.                       |
1164| 8300999  | Unknown error code.                          |
1165
1166**Example**
1167
1168```ts
1169import sms from '@ohos.telephony.sms';
1170import { BusinessError } from '@ohos.base';
1171
1172let slotId: number = 0;
1173let promise = sms.getAllSimMessages(slotId);
1174promise.then((data: sms.SimShortMessage[]) => {
1175    console.log(`getAllSimMessages success, promise: data->${JSON.stringify(data)}`);
1176}).catch((err: BusinessError) => {
1177    console.error(`getAllSimMessages failed, promise: err->${JSON.stringify(err)}`);
1178});
1179```
1180
1181## sms.setCBConfig<sup>7+</sup>
1182
1183setCBConfig\(options: CBConfigOptions, callback: AsyncCallback\<void\>\): void
1184
1185Sets the cell broadcast configuration. This API uses an asynchronous callback to return the result.
1186
1187**System API**: This is a system API.
1188
1189**Required permissions**: ohos.permission.RECEIVE_SMS
1190
1191**System capability**: SystemCapability.Telephony.SmsMms
1192
1193**Parameters**
1194
1195| Name  | Type                                | Mandatory| Description        |
1196| -------- | ------------------------------------ | ---- | ------------ |
1197| options  | [CBConfigOptions](#cbconfigoptions7) | Yes  | Cell broadcast configuration options.|
1198| callback | AsyncCallback&lt;void&gt;            | Yes  | Callback used to return the result.  |
1199
1200**Error codes**
1201
1202For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1203
1204| ID|                  Error Message                   |
1205| -------- | -------------------------------------------- |
1206| 201      | Permission denied.                           |
1207| 202      | Non-system applications use system APIs.     |
1208| 401      | Parameter error.                             |
1209| 8300001  | Invalid parameter value.                     |
1210| 8300002  | Operation failed. Cannot connect to service. |
1211| 8300003  | System internal error.                       |
1212| 8300999  | Unknown error code.                          |
1213
1214**Example**
1215
1216```ts
1217import sms from '@ohos.telephony.sms';
1218import { BusinessError } from '@ohos.base';
1219
1220let cbConfigOptions: sms.CBConfigOptions = {
1221    slotId: 0,
1222    enable: true,
1223    startMessageId: 100,
1224    endMessageId: 200,
1225    ranType: sms.RanType.TYPE_GSM
1226};
1227sms.setCBConfig(cbConfigOptions, (err: BusinessError) => {
1228      console.log(`callback: err->${JSON.stringify(err)}`);
1229});
1230```
1231
1232
1233## sms.setCBConfig<sup>7+</sup>
1234
1235setCBConfig\(options: CBConfigOptions\): Promise\<void\>
1236
1237Sets the cell broadcast configuration. This API uses a promise to return the result.
1238
1239**System API**: This is a system API.
1240
1241**Required permissions**: ohos.permission.RECEIVE_SMS
1242
1243**System capability**: SystemCapability.Telephony.SmsMms
1244
1245**Parameters**
1246
1247| Name | Type                                | Mandatory| Description        |
1248| ------- | ------------------------------------ | ---- | ------------ |
1249| options | [CBConfigOptions](#cbconfigoptions7) | Yes  | Cell broadcast configuration options.|
1250
1251**Return value**
1252
1253| Type               | Description                         |
1254| ------------------- | ----------------------------- |
1255| Promise&lt;void&gt; | Promise used to return the result.|
1256
1257**Error codes**
1258
1259For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1260
1261| ID|                  Error Message                   |
1262| -------- | -------------------------------------------- |
1263| 201      | Permission denied.                           |
1264| 202      | Non-system applications use system APIs.     |
1265| 401      | Parameter error.                             |
1266| 8300001  | Invalid parameter value.                     |
1267| 8300002  | Operation failed. Cannot connect to service. |
1268| 8300003  | System internal error.                       |
1269| 8300999  | Unknown error code.                          |
1270
1271**Example**
1272
1273```ts
1274import sms from '@ohos.telephony.sms';
1275import { BusinessError } from '@ohos.base';
1276
1277let cbConfigOptions: sms.CBConfigOptions = {
1278    slotId: 0,
1279    enable: true,
1280    startMessageId: 100,
1281    endMessageId: 200,
1282    ranType: sms.RanType.TYPE_GSM
1283};
1284let promise = sms.setCBConfig(cbConfigOptions);
1285promise.then(() => {
1286    console.log(`setCBConfig success.`);
1287}).catch((err: BusinessError) => {
1288    console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`);
1289});
1290```
1291
1292## sms.getSmsSegmentsInfo<sup>8+</sup>
1293
1294getSmsSegmentsInfo\(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback\<SmsSegmentsInfo\>\): void
1295
1296Obtains SMS message segment information. This API uses an asynchronous callback to return the result.
1297
1298**System API**: This is a system API.
1299
1300**System capability**: SystemCapability.Telephony.SmsMms
1301
1302**Parameters**
1303
1304| Name   | Type                                                        | Mandatory| Description                                     |
1305| --------- | ------------------------------------------------------------ | ---- | ----------------------------------------- |
1306| slotId    | number                                                       | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
1307| message   | string                                                       | Yes  | SMS message.                                     |
1308| force7bit | boolean                                                      | Yes  | Whether to use 7-bit coding.                         |
1309| callback  | AsyncCallback&lt;[SmsSegmentsInfo](#smssegmentsinfo8)&gt; | Yes  | Callback used to return the result.  |
1310
1311**Error codes**
1312
1313For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1314
1315| ID|                 Error Message                    |
1316| -------- | -------------------------------------------- |
1317| 202      | Non-system applications use system APIs.     |
1318| 401      | Parameter error.                             |
1319| 8300001  | Invalid parameter value.                     |
1320| 8300002  | Operation failed. Cannot connect to service. |
1321| 8300003  | System internal error.                       |
1322| 8300999  | Unknown error code.                          |
1323
1324**Example**
1325
1326```ts
1327import sms from '@ohos.telephony.sms';
1328import { BusinessError } from '@ohos.base';
1329
1330let slotId: number = 0;
1331sms.getSmsSegmentsInfo(slotId, "message", false, (err: BusinessError, data: sms.SmsSegmentsInfo) => {
1332      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1333});
1334```
1335
1336
1337## sms.getSmsSegmentsInfo<sup>8+</sup>
1338
1339getSmsSegmentsInfo\(slotId: number, message: string, force7bit: boolean\): Promise\<SmsSegmentsInfo\>
1340
1341Obtains SMS message segment information. This API uses a promise to return the result.
1342
1343**System API**: This is a system API.
1344
1345**System capability**: SystemCapability.Telephony.SmsMms
1346
1347**Parameters**
1348
1349| Name   | Type   | Mandatory| Description                                     |
1350| --------- | ------- | ---- | ----------------------------------------- |
1351| slotId    | number  | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
1352| message   | string  | Yes  | SMS message.                                     |
1353| force7bit | boolean | Yes  | Whether to use 7-bit coding.                         |
1354
1355**Return value**
1356
1357| Type                                                   | Description                         |
1358| ------------------------------------------------------- | ----------------------------- |
1359| Promise&lt;[SmsSegmentsInfo](#smssegmentsinfo8)&gt; | Promise used to return the result.|
1360
1361**Error codes**
1362
1363For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1364
1365| ID|                 Error Message                    |
1366| -------- | -------------------------------------------- |
1367| 202      | Non-system applications use system APIs.     |
1368| 401      | Parameter error.                             |
1369| 8300001  | Invalid parameter value.                     |
1370| 8300002  | Operation failed. Cannot connect to service. |
1371| 8300003  | System internal error.                       |
1372| 8300999  | Unknown error code.                          |
1373
1374**Example**
1375
1376```ts
1377import sms from '@ohos.telephony.sms';
1378import { BusinessError } from '@ohos.base';
1379
1380let slotId: number = 0;
1381let promise = sms.getSmsSegmentsInfo(slotId, "message", false);
1382promise.then((data: sms.SmsSegmentsInfo) => {
1383    console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`);
1384}).catch((err: BusinessError) => {
1385    console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`);
1386});
1387```
1388
1389## sms.isImsSmsSupported<sup>8+</sup>
1390
1391isImsSmsSupported\(slotId: number, callback: AsyncCallback\<boolean\>\): void
1392
1393Checks whether SMS is supported on IMS. This API uses an asynchronous callback to return the result.
1394
1395**System API**: This is a system API.
1396
1397**System capability**: SystemCapability.Telephony.SmsMms
1398
1399**Parameters**
1400
1401| Name  | Type                        | Mandatory| Description      |
1402| -------- | ---------------------------- | ---- | ---------- |
1403| slotId   | number                       | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
1404| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.|
1405
1406**Error codes**
1407
1408For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1409
1410| ID|                 Error Message                    |
1411| -------- | -------------------------------------------- |
1412| 202      | Non-system applications use system APIs.     |
1413| 401      | Parameter error.                             |
1414| 8300001  | Invalid parameter value.                     |
1415| 8300002  | Operation failed. Cannot connect to service. |
1416| 8300003  | System internal error.                       |
1417| 8300999  | Unknown error code.                          |
1418
1419**Example**
1420
1421```ts
1422import sms from '@ohos.telephony.sms';
1423import { BusinessError } from '@ohos.base';
1424
1425let slotId: number = 0;
1426sms.isImsSmsSupported(slotId, (err: BusinessError, data: boolean) => {
1427      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1428});
1429```
1430
1431
1432## sms.isImsSmsSupported<sup>8+</sup>
1433
1434isImsSmsSupported\(slotId: number\): Promise\<boolean\>
1435
1436Checks whether SMS is supported on IMS. This API uses a promise to return the result.
1437
1438**System API**: This is a system API.
1439
1440**System capability**: SystemCapability.Telephony.SmsMms
1441
1442**Parameters**
1443
1444| Name| Type  | Mandatory | Description                                 |
1445| ------ | ------ | ---- | -------------------------------------- |
1446| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1447
1448**Return value**
1449
1450| Type                  | Description                   |
1451| ---------------------- | ----------------------- |
1452| Promise&lt;boolean&gt; | Promise used to return the result.|
1453
1454**Error codes**
1455
1456For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1457
1458| ID|                 Error Message                    |
1459| -------- | -------------------------------------------- |
1460| 202      | Non-system applications use system APIs.     |
1461| 401      | Parameter error.                             |
1462| 8300001  | Invalid parameter value.                     |
1463| 8300002  | Operation failed. Cannot connect to service. |
1464| 8300003  | System internal error.                       |
1465| 8300999  | Unknown error code.                          |
1466
1467**Example**
1468
1469```ts
1470import sms from '@ohos.telephony.sms';
1471import { BusinessError } from '@ohos.base';
1472
1473let slotId: number = 0;
1474let promise = sms.isImsSmsSupported(slotId);
1475promise.then((data: boolean) => {
1476    console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`);
1477}).catch((err: BusinessError) => {
1478    console.error(`isImsSmsSupported failed, promise: err->${JSON.stringify(err)}`);
1479});
1480```
1481
1482## sms.getImsShortMessageFormat<sup>8+</sup>
1483
1484getImsShortMessageFormat\(callback: AsyncCallback\<string\>\): void
1485
1486Obtains the SMS format supported by the IMS, for example, **3gpp**, **3gpp2**, or **unknown**. This API uses an asynchronous callback to return the result.
1487
1488**System API**: This is a system API.
1489
1490**System capability**: SystemCapability.Telephony.SmsMms
1491
1492**Parameters**
1493
1494| Name  | Type                       | Mandatory| Description      |
1495| -------- | --------------------------- | ---- | ---------- |
1496| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.|
1497
1498**Error codes**
1499
1500For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1501
1502| ID|                  Error Message                   |
1503| -------- | -------------------------------------------- |
1504| 202      | Non-system applications use system APIs.     |
1505| 401      | Parameter error.                             |
1506| 8300001  | Invalid parameter value.                     |
1507| 8300002  | Operation failed. Cannot connect to service. |
1508| 8300003  | System internal error.                       |
1509| 8300999  | Unknown error code.                          |
1510
1511**Example**
1512
1513```ts
1514import sms from '@ohos.telephony.sms';
1515import { BusinessError } from '@ohos.base';
1516
1517sms.getImsShortMessageFormat((err: BusinessError, data: string) => {
1518      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1519});
1520```
1521
1522
1523## sms.getImsShortMessageFormat<sup>8+</sup>
1524
1525getImsShortMessageFormat\(\): Promise\<string\>
1526
1527Obtains the SMS format supported by the IMS. This API uses a promise to return the result.
1528
1529**System API**: This is a system API.
1530
1531**System capability**: SystemCapability.Telephony.SmsMms
1532
1533**Return value**
1534
1535| Type                 | Description                      |
1536| --------------------- | -------------------------- |
1537| Promise&lt;string&gt; | Promise used to return the result. |
1538
1539**Error codes**
1540
1541For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1542
1543| ID|                  Error Message                   |
1544| -------- | -------------------------------------------- |
1545| 202      | Non-system applications use system APIs.     |
1546| 8300002  | Operation failed. Cannot connect to service. |
1547| 8300003  | System internal error.                       |
1548| 8300999  | Unknown error code.                          |
1549
1550**Example**
1551
1552```ts
1553import sms from '@ohos.telephony.sms';
1554import { BusinessError } from '@ohos.base';
1555
1556sms.getImsShortMessageFormat().then((data: string) => {
1557    console.log(`getImsShortMessageFormat success, promise: data->${JSON.stringify(data)}`);
1558}).catch((err: BusinessError) => {
1559    console.error(`getImsShortMessageFormat failed, promise: err->${JSON.stringify(err)}`);
1560});
1561```
1562
1563## sms.decodeMms<sup>8+</sup>
1564
1565decodeMms\(mmsFilePathName: string | Array\<number\>, callback: AsyncCallback\<MmsInformation\>\): void
1566
1567Decodes MMS messages. This API uses an asynchronous callback to return the result.
1568
1569**System API**: This is a system API.
1570
1571**System capability**: SystemCapability.Telephony.SmsMms
1572
1573**Parameters**
1574
1575| Name         | Type                                                   | Mandatory| Description          |
1576| --------------- | ------------------------------------------------------- | ---- | -------------- |
1577| mmsFilePathName | string \|Array<number\>                                 | Yes  | MMS message file path.|
1578| callback        | AsyncCallback&lt;[MmsInformation](#mmsinformation8)&gt; | Yes  | Callback used to return the result.    |
1579
1580**Error codes**
1581
1582For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1583
1584| ID|                 Error Message                    |
1585| -------- | -------------------------------------------- |
1586| 202      | Non-system applications use system APIs.     |
1587| 401      | Parameter error.                             |
1588| 8300001  | Invalid parameter value.                     |
1589| 8300002  | Operation failed. Cannot connect to service. |
1590| 8300003  | System internal error.                       |
1591| 8300999  | Unknown error code.                          |
1592
1593**Example**
1594
1595```ts
1596import sms from '@ohos.telephony.sms';
1597import { BusinessError } from '@ohos.base';
1598
1599let mmsFilePathName: string = "filename";
1600sms.decodeMms(mmsFilePathName, (err: BusinessError, data: sms.MmsInformation) => {
1601      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1602});
1603```
1604
1605
1606## sms.decodeMms<sup>8+</sup>
1607
1608decodeMms\(mmsFilePathName: string | Array\<number\>\): Promise\<MmsInformation\>
1609
1610Decodes MMS messages. This API uses a promise to return the result.
1611
1612**System API**: This is a system API.
1613
1614**System capability**: SystemCapability.Telephony.SmsMms
1615
1616**Parameters**
1617
1618| Name         | Type                   | Mandatory| Description          |
1619| --------------- | ----------------------- | ---- | -------------- |
1620| mmsFilePathName | string \|Array<number\> | Yes  | MMS message file path.|
1621
1622**Return value**
1623
1624| Type                                                     | Description                       |
1625| --------------------------------------------------------- | --------------------------- |
1626| Promise&lt;&lt;[MmsInformation](#mmsinformation8)&gt;&gt; | Promise used to return the result.|
1627
1628**Error codes**
1629
1630For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1631
1632| ID|                 Error Message                    |
1633| -------- | -------------------------------------------- |
1634| 202      | Non-system applications use system APIs.     |
1635| 401      | Parameter error.                             |
1636| 8300001  | Invalid parameter value.                     |
1637| 8300002  | Operation failed. Cannot connect to service. |
1638| 8300003  | System internal error.                       |
1639| 8300999  | Unknown error code.                          |
1640
1641**Example**
1642
1643```ts
1644import sms from '@ohos.telephony.sms';
1645import { BusinessError } from '@ohos.base';
1646
1647let mmsFilePathName: string = "filename";
1648let promise = sms.decodeMms(mmsFilePathName);
1649promise.then((data: sms.MmsInformation) => {
1650    console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`);
1651}).catch((err: BusinessError) => {
1652    console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`);
1653});
1654```
1655
1656## sms.encodeMms<sup>8+</sup>
1657
1658encodeMms\(mms: MmsInformation, callback: AsyncCallback\<Array\<number\>\>\): void
1659
1660MMS message code. This API uses an asynchronous callback to return the result.
1661
1662**System API**: This is a system API.
1663
1664**System capability**: SystemCapability.Telephony.SmsMms
1665
1666**Parameters**
1667
1668| Name  | Type                               | Mandatory| Description      |
1669| -------- | ----------------------------------- | ---- | ---------- |
1670| mms      | [MmsInformation](#mmsinformation8)  | Yes  | MMS message information.|
1671| callback | AsyncCallback&lt;Array<number\>&gt; | Yes  | Callback used to return the result.|
1672
1673**Error codes**
1674
1675For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1676
1677| ID|                 Error Message                    |
1678| -------- | -------------------------------------------- |
1679| 202      | Non-system applications use system APIs.     |
1680| 401      | Parameter error.                             |
1681| 8300001  | Invalid parameter value.                     |
1682| 8300002  | Operation failed. Cannot connect to service. |
1683| 8300003  | System internal error.                       |
1684| 8300999  | Unknown error code.                          |
1685
1686**Example**
1687
1688```ts
1689import sms from '@ohos.telephony.sms';
1690import { BusinessError } from '@ohos.base';
1691
1692let mmsAcknowledgeInd: sms.MmsAcknowledgeInd = {
1693    transactionId: "100",
1694    version: sms.MmsVersionType.MMS_VERSION_1_0,
1695    reportAllowed: sms.ReportType.MMS_YES
1696};
1697let mmsInformation: sms.MmsInformation = {
1698    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
1699    mmsType: mmsAcknowledgeInd
1700};
1701sms.encodeMms(mmsInformation, (err: BusinessError, data: number[]) => {
1702      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1703});
1704```
1705
1706
1707## sms.encodeMms<sup>8+</sup>
1708
1709encodeMms\(mms: MmsInformation\): Promise\<Array\<number\>\>
1710
1711MMS message code. This API uses a promise to return the result.
1712
1713**System API**: This is a system API.
1714
1715**System capability**: SystemCapability.Telephony.SmsMms
1716
1717**Parameters**
1718
1719| Name| Type                              | Mandatory| Description      |
1720| ------ | ---------------------------------- | ---- | ---------- |
1721| mms    | [MmsInformation](#mmsinformation8) | Yes  | MMS message information.|
1722
1723**Return value**
1724
1725| Type                         | Description                               |
1726| ----------------------------- | ----------------------------------- |
1727| Promise&lt;Array<number\>&gt; | Promise used to return the result.|
1728
1729**Error codes**
1730
1731For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1732
1733| ID|                 Error Message                    |
1734| -------- | -------------------------------------------- |
1735| 202      | Non-system applications use system APIs.     |
1736| 401      | Parameter error.                             |
1737| 8300001  | Invalid parameter value.                     |
1738| 8300002  | Operation failed. Cannot connect to service. |
1739| 8300003  | System internal error.                       |
1740| 8300999  | Unknown error code.                          |
1741
1742**Example**
1743
1744```ts
1745import sms from '@ohos.telephony.sms';
1746import { BusinessError } from '@ohos.base';
1747
1748let mmsAcknowledgeInd: sms.MmsAcknowledgeInd = {
1749    transactionId: "100",
1750    version: sms.MmsVersionType.MMS_VERSION_1_0,
1751    reportAllowed: sms.ReportType.MMS_YES
1752};
1753let mmsInformation: sms.MmsInformation = {
1754    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
1755    mmsType: mmsAcknowledgeInd
1756};
1757sms.encodeMms(mmsInformation).then((data: number[]) => {
1758    console.log(`encodeMms success, promise: data->${JSON.stringify(data)}`);
1759}).catch((err: BusinessError) => {
1760    console.error(`encodeMms failed, promise: err->${JSON.stringify(err)}`);
1761});
1762```
1763
1764## sms.getDefaultSmsSimId<sup>10+</sup>
1765
1766getDefaultSmsSimId\(callback: AsyncCallback&lt;number&gt;\): void
1767
1768Obtains the default ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
1769
1770**System capability**: SystemCapability.Telephony.SmsMms
1771
1772**Parameters**
1773
1774| Name  | Type                       | Mandatory| Description                                    |
1775| -------- | --------------------------- | ---- | ---------------------------------------- |
1776| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the result.<br>The return value is bound to the SIM card and increases from 1.|
1777
1778**Error codes**
1779
1780For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1781
1782| ID|                 Error Message                    |
1783| -------- | -------------------------------------------- |
1784| 401      | Parameter error.                             |
1785| 8300001  | Invalid parameter value.                     |
1786| 8300002  | Operation failed. Cannot connect to service. |
1787| 8300003  | System internal error.                       |
1788| 8300004  | Do not have sim card.                        |
1789| 8300999  | Unknown error code.                          |
1790| 8301001  | SIM card is not activated.                   |
1791
1792**Example**
1793
1794```ts
1795import sms from '@ohos.telephony.sms';
1796import { BusinessError } from '@ohos.base';
1797
1798sms.getDefaultSmsSimId((err: BusinessError, data: number) => {
1799    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1800});
1801```
1802
1803
1804## sms.getDefaultSmsSimId<sup>10+</sup>
1805
1806getDefaultSmsSimId\(\): Promise&lt;number&gt;
1807
1808Obtains the default ID of the SIM card used to send SMS messages. This API uses a promise to return the result.
1809
1810**System capability**: SystemCapability.Telephony.SmsMms
1811
1812**Return value**
1813
1814| Type           | Description                                                        |
1815| --------------- | ------------------------------------------------------------ |
1816| Promise&lt;number&gt; | Promise used to return the result.<br>The return value is bound to the SIM card and increases from 1.|
1817
1818**Error codes**
1819
1820For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1821
1822| ID|                 Error Message                    |
1823| -------- | -------------------------------------------- |
1824| 8300001  | Invalid parameter value.                     |
1825| 8300002  | Operation failed. Cannot connect to service. |
1826| 8300003  | System internal error.                       |
1827| 8300004  | Do not have sim card.                        |
1828| 8300999  | Unknown error code.                          |
1829| 8301001  | SIM card is not activated.                   |
1830
1831**Example**
1832
1833```ts
1834import sms from '@ohos.telephony.sms';
1835import { BusinessError } from '@ohos.base';
1836
1837let promise = sms.getDefaultSmsSimId();
1838promise.then((data: number) => {
1839    console.log(`getDefaultSmsSimId success, promise: data->${JSON.stringify(data)}`);
1840}).catch((err: BusinessError) => {
1841    console.error(`getDefaultSmsSimId failed, promise: err->${JSON.stringify(err)}`);
1842});
1843```
1844
1845## ShortMessage
1846
1847Defines an SMS message instance.
1848
1849**System capability**: SystemCapability.Telephony.SmsMms
1850
1851|         Name            |                  Type                  | Mandatory| Description                                                        |
1852| ------------------------ | --------------------------------------- | ---- | ------------------------------------------------------------ |
1853| 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. |
1854| 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**.|
1855| 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.|
1856| messageClass             | [ShortMessageClass](#shortmessageclass) |  Yes | Enumerates SMS message types.                                                  |
1857| pdu                      | Array&lt;number&gt;                     |  Yes | PDU in the SMS message.                           |
1858| protocolId               | number                                  |  Yes | Protocol identifier used for delivering the SMS message.                                  |
1859| scAddress                | string                                  |  Yes | SMSC address.                                |
1860| scTimestamp              | number                                  |  Yes | SMSC timestamp.                                                |
1861| status                   | number                                  |  Yes | SMS message status sent by the SMSC in the **SMS-STATUS-REPORT** message.|
1862| visibleMessageBody       | string                                  |  Yes | SMS message body.                                                  |
1863| visibleRawAddress        | string                                  |  Yes | Sender address.                                                |
1864
1865
1866## ShortMessageClass
1867
1868Enumerates SMS message types.
1869
1870**System capability**: SystemCapability.Telephony.SmsMms
1871
1872| Name            | Value  | Description                                    |
1873| ---------------- | ---- | ---------------------------------------- |
1874| UNKNOWN          | 0    | Unknown type.                              |
1875| INSTANT_MESSAGE  | 1    | Instant message, which is displayed immediately after being received.              |
1876| OPTIONAL_MESSAGE | 2    | Message stored in the device or SIM card.             |
1877| SIM_MESSAGE      | 3    | Message containing SIM card information, which is to be stored in the SIM card.|
1878| FORWARD_MESSAGE  | 4    | Message to be forwarded to another device.              |
1879
1880
1881## SendMessageOptions
1882
1883Provides the options (including callbacks) for sending SMS messages. For example, you can specify the SMS message type by the optional parameter **content**.
1884
1885**System capability**: SystemCapability.Telephony.SmsMms
1886
1887|       Name      | Type                                                        | Mandatory| Description                                                        |
1888| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1889| slotId           | number                                                       | Yes  | Slot ID of the SIM card used for sending SMS messages. <br>- **0**: card slot 1<br>- **1**: card slot 2     |
1890| destinationHost  | string                                                       | Yes  | Destination address of the SMS message.                                            |
1891| 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.|
1892| serviceCenter    | string                                                       | No  | SMSC address. By default, the SMSC address in the SIM card is used.               |
1893| destinationPort  | number                                                       | No  | Destination port of the SMS message. This field is mandatory only for a data message. Otherwise, it is optional.  |
1894| sendCallback     | AsyncCallback&lt;[ISendShortMessageCallback](#isendshortmessagecallback)&gt; | No  | Callback used to return the SMS message sending result. For details, see [ISendShortMessageCallback](#isendshortmessagecallback).|
1895| deliveryCallback | AsyncCallback&lt;[IDeliveryShortMessageCallback](#ideliveryshortmessagecallback)&gt; | No  | Callback used to return the SMS message delivery report. For details, see [IDeliveryShortMessageCallback](#ideliveryshortmessagecallback).|
1896
1897
1898## ISendShortMessageCallback
1899
1900Provides 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.
1901
1902**System capability**: SystemCapability.Telephony.SmsMms
1903
1904|   Name    | Type                           | Mandatory|                                               Description                                        |
1905| ---------- | ------------------------------- | ---- | ----------------------------------------------------------------------------------------- |
1906| isLastPart | boolean                         | Yes  | 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**.|
1907| result     | [SendSmsResult](#sendsmsresult) | Yes  | SMS message sending result.                                                                            |
1908| url        | string                          | Yes  | URI for storing the sent SMS message.                                                                       |
1909
1910
1911## IDeliveryShortMessageCallback
1912
1913Provides the callback for the SMS message delivery report.
1914
1915**System capability**: SystemCapability.Telephony.SmsMms
1916
1917| Name| Type               | Mandatory| Description          |
1918| ---- | ------------------- | ---- | -------------- |
1919| pdu  | Array&lt;number&gt; | Yes  | SMS message delivery report.|
1920
1921
1922## SendSmsResult
1923
1924Enumerates SMS message sending results.
1925
1926**System capability**: SystemCapability.Telephony.SmsMms
1927
1928| Name                                | Value  | Description                                                  |
1929| ------------------------------------ | ---- | ------------------------------------------------------ |
1930| SEND_SMS_SUCCESS                     | 0    | The SMS message is sent successfully.                                        |
1931| SEND_SMS_FAILURE_UNKNOWN             | 1    | Failed to send the SMS message due to an unknown reason.                              |
1932| SEND_SMS_FAILURE_RADIO_OFF           | 2    | Failed to send the SMS message because the modem is shut down.                  |
1933| 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.|
1934
1935## MmsInformation<sup>8+</sup>
1936
1937Defines the MMS message information.
1938
1939**System API**: This is a system API.
1940
1941**System capability**: SystemCapability.Telephony.SmsMms
1942
1943|     Name   | Type                                                        | Mandatory|    Description   |
1944| ----------- | ------------------------------------------------------------ | ---- | ---------- |
1945| messageType | [MessageType](#messagetype8)                                 | Yes  | Message type.|
1946| mmsType     | [MmsSendReq](#mmssendreq8) \|[MmsSendConf](#mmssendconf8) \|[MmsNotificationInd](#mmsnotificationind8) \|[MmsRespInd](#mmsrespind8) \|[MmsRetrieveConf](#mmsretrieveconf8)\|[MmsAcknowledgeInd](#mmsacknowledgeind8)\|[MmsDeliveryInd](#mmsdeliveryind8)\|[MmsReadOrigInd](#mmsreadorigind8)\|[MmsReadRecInd](#mmsreadrecind8) | Yes  | PDU header type.|
1947| attachment  | Array<[MmsAttachment](#mmsattachment8)\>                     | No  | Attachment.     |
1948
1949## MmsSendReq<sup>8+</sup>
1950
1951Defines an MMS message sending request.
1952
1953**System API**: This is a system API.
1954
1955**System capability**: SystemCapability.Telephony.SmsMms
1956
1957|       Name      | Type                                | Mandatory| Description        |
1958| ---------------- | ------------------------------------ | ---- | ------------ |
1959| from             | [MmsAddress](#mmsaddress8)           | Yes  | MMS message source.    |
1960| transactionId    | string                               | Yes  | Transaction ID.      |
1961| contentType      | string                               | Yes  | Content type.    |
1962| version          | [MmsVersionType](#mmsversiontype8)   | Yes  | Version.        |
1963| to               | Array<[MmsAddress](#mmsaddress8)\>   | No  | Destination address.      |
1964| date             | number                               | No  | Date.        |
1965| cc               | Array<[MmsAddress](#mmsaddress8)\>   | No  | Carbon copy.        |
1966| bcc              | Array<[MmsAddress](#mmsaddress8)\>   | No  | Blind carbon copy.      |
1967| subject          | string                               | No  | Subject.        |
1968| messageClass     | number                               | No  | Message class.      |
1969| expiry           | number                               | No  | Expiration.        |
1970| priority         | [MmsPriorityType](#mmsprioritytype8) | No  | Priority.        |
1971| senderVisibility | number                               | No  | Sender visibility.|
1972| deliveryReport   | number                               | No  | Delivery report.    |
1973| readReport       | number                               | No  | Read report.    |
1974
1975## MmsSendConf<sup>8+</sup>
1976
1977Defines the MMS message sending configuration.
1978
1979**System API**: This is a system API.
1980
1981**System capability**: SystemCapability.Telephony.SmsMms
1982
1983|     Name     | Type                              | Mandatory| Description    |
1984| ------------- | ---------------------------------- | ---- | -------- |
1985| responseState | number                             | Yes  | Response status.|
1986| transactionId | string                             | Yes  | Transaction ID.  |
1987| version       | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
1988| messageId     | string                             | No  | Message ID.  |
1989
1990## MmsNotificationInd<sup>8+</sup>
1991
1992Defines an MMS notification index.
1993
1994**System API**: This is a system API.
1995
1996**System capability**: SystemCapability.Telephony.SmsMms
1997
1998|      Name      | Type                              | Mandatory| Description    |
1999| --------------- | ---------------------------------- | ---- | -------- |
2000| transactionId   | string                             | Yes  | Transaction ID.  |
2001| messageClass    | number                             | Yes  | Message class.  |
2002| messageSize     | number                             | Yes  | Message size.|
2003| expiry          | number                             | Yes  | Expiration.    |
2004| contentLocation | string                             | Yes  | Content location.|
2005| version         | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
2006| from            | [MmsAddress](#mmsaddress8)         | No  | Source address.    |
2007| subject         | string                             | No  | Subject.    |
2008| deliveryReport  | number                             | No  | Status report.|
2009| contentClass    | number                             | No  | Content class.  |
2010
2011## MmsAcknowledgeInd<sup>8+</sup>
2012
2013Defines an MMS confirmation index.
2014
2015**System API**: This is a system API.
2016
2017**System capability**: SystemCapability.Telephony.SmsMms
2018
2019|      Name    | Type                              | Mandatory| Description    |
2020| ------------- | ---------------------------------- | ---- | -------- |
2021| transactionId | string                             | Yes  | Transaction ID.  |
2022| version       | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
2023| reportAllowed | [ReportType](#reporttype8)         | No  | Report allowed.|
2024
2025## MmsRetrieveConf<sup>8+</sup>
2026
2027Defines the MMS message retrieval configuration.
2028
2029**System API**: This is a system API.
2030
2031**System capability**: SystemCapability.Telephony.SmsMms
2032
2033|      Name     | Type                                | Mandatory| Description    |
2034| -------------- | ------------------------------------ | ---- | -------- |
2035| transactionId  | string                               | Yes  | Transaction ID.  |
2036| messageId      | string                               | Yes  | Message ID.  |
2037| date           | number                               | Yes  | Date.    |
2038| contentType    | string                               | Yes  | Content type.|
2039| to             | Array<[MmsAddress](#mmsaddress8)\>   | Yes  | Destination address.  |
2040| version        | [MmsVersionType](#mmsversiontype8)   | Yes  | Version.    |
2041| from           | [MmsAddress](#mmsaddress8)           | No  | Source address.    |
2042| cc             | Array<[MmsAddress](#mmsaddress8)\>   | No  | Carbon copy.    |
2043| subject        | string                               | No  | Subject.    |
2044| priority       | [MmsPriorityType](#mmsprioritytype8) | No  | Priority.  |
2045| deliveryReport | number                               | No  | Status report.|
2046| readReport     | number                               | No  | Read report.|
2047| retrieveStatus | number                               | No  | Retrieval status.|
2048| retrieveText   | string                               | No  | Retrieval text.|
2049
2050## MmsReadOrigInd<sup>8+</sup>
2051
2052Defines the original MMS message reading index.
2053
2054**System API**: This is a system API.
2055
2056**System capability**: SystemCapability.Telephony.SmsMms
2057
2058|    Name   | Type                              | Mandatory| Description    |
2059| ---------- | ---------------------------------- | ---- | -------- |
2060| version    | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
2061| messageId  | string                             | Yes  | Message ID.  |
2062| to         | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.  |
2063| from       | [MmsAddress](#mmsaddress8)         | Yes  | Source address.    |
2064| date       | number                             | Yes  | Date.    |
2065| readStatus | number                             | Yes  | Read status.|
2066
2067## MmsReadRecInd<sup>8+</sup>
2068
2069Defines the MMS message reading index.
2070
2071**System API**: This is a system API.
2072
2073**System capability**: SystemCapability.Telephony.SmsMms
2074
2075|    Name   | Type                              | Mandatory| Description    |
2076| ---------- | ---------------------------------- | ---- | -------- |
2077| version    | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
2078| messageId  | string                             | Yes  | Message ID.  |
2079| to         | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.  |
2080| from       | [MmsAddress](#mmsaddress8)         | Yes  | Source address.    |
2081| readStatus | number                             | Yes  | Read status.|
2082| date       | number                             | No  | Date.    |
2083
2084## MmsAttachment<sup>8+</sup>
2085
2086Defines the attachment of an MMS message.
2087
2088**System API**: This is a system API.
2089
2090**System capability**: SystemCapability.Telephony.SmsMms
2091
2092|          Name          | Type                                | Mandatory| Description              |
2093| ----------------------- | ------------------------------------ | ---- | ------------------ |
2094| contentId               | string                               | Yes  | Content ID.            |
2095| contentLocation         | string                               | Yes  | Content location.          |
2096| contentDisposition      | [DispositionType](#dispositiontype8) | Yes  | Content disposition.          |
2097| contentTransferEncoding | string                               | Yes  | Encoding for content transfer.      |
2098| contentType             | string                               | Yes  | Content type.          |
2099| isSmil                  | boolean                              | Yes  | Whether the synchronized multimedia integration language is used.|
2100| path                    | string                               | No  | Path.              |
2101| inBuff                  | Array<number\>                       | No  | Whether the message is in the buffer.          |
2102| fileName                | string                               | No  | File name.            |
2103| charset                 | [MmsCharSets](#mmscharsets8)         | No  | Character set.            |
2104
2105## MmsAddress<sup>8+</sup>
2106
2107Defines an MMSC address.
2108
2109**System API**: This is a system API.
2110
2111**System capability**: SystemCapability.Telephony.SmsMms
2112
2113|   Name | Type                        | Mandatory| Description  |
2114| ------- | ---------------------------- | ---- | ------ |
2115| address | string                       | Yes  | Network address.  |
2116| charset | [MmsCharSets](#mmscharsets8) | Yes  | Character set.|
2117
2118## MessageType<sup>8+</sup>
2119
2120Message type.
2121
2122**System API**: This is a system API.
2123
2124**System capability**: SystemCapability.Telephony.SmsMms
2125
2126|          Name            | Value  | Description                |
2127| ------------------------- | ---- | -------------------- |
2128| TYPE_MMS_SEND_REQ         | 128  | MMS message sending request.    |
2129| TYPE_MMS_SEND_CONF        | 129  | MMS message sending configuration.    |
2130| TYPE_MMS_NOTIFICATION_IND | 130  | MMS notification index.    |
2131| TYPE_MMS_RESP_IND         | 131  | MMS message response index.    |
2132| TYPE_MMS_RETRIEVE_CONF    | 132  | MMS message retrieval configuration.    |
2133| TYPE_MMS_ACKNOWLEDGE_IND  | 133  | MMS message acknowledgement index.    |
2134| TYPE_MMS_DELIVERY_IND     | 134  | MMS message delivery index.    |
2135| TYPE_MMS_READ_REC_IND     | 135  | MMS message reading and receiving index.|
2136| TYPE_MMS_READ_ORIG_IND    | 136  | Original MMS message reading index.|
2137
2138## MmsPriorityType<sup>8+</sup>
2139
2140Enumerates MMS message priorities.
2141
2142**System API**: This is a system API.
2143
2144**System capability**: SystemCapability.Telephony.SmsMms
2145
2146|    Name   | Value  | Description          |
2147| ---------- | ---- | -------------- |
2148| MMS_LOW    | 128  | Low priority.  |
2149| MMS_NORMAL | 129  | Normal priority.|
2150| MMS_HIGH   | 130  | High priority.  |
2151
2152## MmsVersionType<sup>8+</sup>
2153
2154Enumerates MMS versions.
2155
2156**System API**: This is a system API.
2157
2158**System capability**: SystemCapability.Telephony.SmsMms
2159
2160|      Name      | Value  | Description       |
2161| --------------- | ---- | ----------- |
2162| MMS_VERSION_1_0 | 0x10 | MMS version 1_0.|
2163| MMS_VERSION_1_1 | 0x11 | MMS version 1_1.|
2164| MMS_VERSION_1_2 | 0x12 | MMS version 1_2.|
2165| MMS_VERSION_1_3 | 0x13 | MMS version 1_3.|
2166
2167## MmsCharSets<sup>8+</sup>
2168
2169Enumerates MMS character sets.
2170
2171**System API**: This is a system API.
2172
2173**System capability**: SystemCapability.Telephony.SmsMms
2174
2175|      Name      | Value    | Description               |
2176| --------------- | ------ | ------------------- |
2177| BIG5            | 0X07EA | BIG5 format.           |
2178| ISO_10646_UCS_2 | 0X03E8 | ISO_10646_UCS_2 format.|
2179| ISO_8859_1      | 0X04   | ISO_8859_1 format.     |
2180| ISO_8859_2      | 0X05   | ISO_8859_2 format.     |
2181| ISO_8859_3      | 0X06   | ISO_8859_3 format.     |
2182| ISO_8859_4      | 0X07   | ISO_8859_4 format.     |
2183| ISO_8859_5      | 0X08   | ISO_8859_5 format.     |
2184| ISO_8859_6      | 0X09   | ISO_8859_6 format.     |
2185| ISO_8859_7      | 0X0A   | ISO_8859_7 format.     |
2186| ISO_8859_8      | 0X0B   | ISO_8859_8 format.     |
2187| ISO_8859_9      | 0X0C   | ISO_8859_9 format.     |
2188| SHIFT_JIS       | 0X11   | SHIFT_JIS format.      |
2189| US_ASCII        | 0X03   | US_ASCII format.       |
2190| UTF_8           | 0X6A   | UTF_8 format.          |
2191
2192## DispositionType<sup>8+</sup>
2193
2194Enumerates disposition types.
2195
2196**System API**: This is a system API.
2197
2198**System capability**: SystemCapability.Telephony.SmsMms
2199
2200|    Name   | Value  | Description    |
2201| ---------- | ---- | -------- |
2202| FROM_DATA  | 0    | Data source.|
2203| ATTACHMENT | 1    | Attachment.    |
2204| INLINE     | 2    | Inlining.    |
2205
2206## ReportType<sup>8+</sup>
2207
2208Enumerates report types.
2209
2210**System API**: This is a system API.
2211
2212**System capability**: SystemCapability.Telephony.SmsMms
2213
2214|  Name  | Value  | Description|
2215| ------- | ---- | ---- |
2216| MMS_YES | 128  | YES  |
2217| MMS_NO  | 129  | NO   |
2218
2219## CBConfigOptions<sup>7+</sup>
2220
2221Defines the cell broadcast configuration options.
2222
2223**System API**: This is a system API.
2224
2225**System capability**: SystemCapability.Telephony.SmsMms
2226
2227|      Name     | Type                | Mandatory| Description        |
2228| -------------- | -------------------- | ---- | ------------ |
2229| slotId         | number               | Yes  | Card slot ID.      |
2230| enable         | boolean              | Yes  | Whether to enable cell broadcast.        |
2231| startMessageId | number               | Yes  | Start message ID.  |
2232| endMessageId   | number               | Yes  | End message ID.  |
2233| ranType        | [RanType](#rantype7) | Yes  | RAN type.|
2234
2235## SimMessageStatus<sup>7+</sup>
2236
2237Defines the SIM message status.
2238
2239**System API**: This is a system API.
2240
2241**System capability**: SystemCapability.Telephony.SmsMms
2242
2243|           Name           | Value  | Description                       |
2244| ------------------------- | ---- | --------------------------- |
2245| SIM_MESSAGE_STATUS_FREE   | 0    | Free state.      |
2246| SIM_MESSAGE_STATUS_READ   | 1    | Read state.               |
2247| SIM_MESSAGE_STATUS_UNREAD | 3    | Unread state.               |
2248| SIM_MESSAGE_STATUS_SENT   | 5    | Storage of sent messages (applicable only to SMS).|
2249| SIM_MESSAGE_STATUS_UNSENT | 7    | Storage of unsent messages (applicable only to SMS).|
2250
2251## RanType<sup>7+</sup>
2252
2253RAN type.
2254
2255**System API**: This is a system API.
2256
2257**System capability**: SystemCapability.Telephony.SmsMms
2258
2259|   Name   | Value  | Description|
2260| --------- | ---- | ---- |
2261| TYPE_GSM  | 1    | GSM  |
2262| TYPE_CDMA | 2    | CMDA |
2263
2264## SmsEncodingScheme<sup>8+</sup>
2265
2266Enumerates SMS encoding schemes.
2267
2268**System API**: This is a system API.
2269
2270**System capability**: SystemCapability.Telephony.SmsMms
2271
2272|         Name        | Value  | Description        |
2273| -------------------- | ---- | ------------ |
2274| SMS_ENCODING_UNKNOWN | 0    | Unknown code.|
2275| SMS_ENCODING_7BIT    | 1    | 7-digit code. |
2276| SMS_ENCODING_8BIT    | 2    | 8-digit code. |
2277| SMS_ENCODING_16BIT   | 3    | 16-digit code.|
2278
2279## SimMessageOptions<sup>7+</sup>
2280
2281Defines the SIM message options.
2282
2283**System API**: This is a system API.
2284
2285**System capability**: SystemCapability.Telephony.SmsMms
2286
2287|  Name | Type                                  | Mandatory| Description          |
2288| ------ | -------------------------------------- | ---- | -------------- |
2289| slotId | number                                 | Yes  | Card slot ID.        |
2290| smsc   | string                                 | Yes  | Short message service center.|
2291| pdu    | string                                 | Yes  | Protocol data unit.  |
2292| status | [SimMessageStatus](#simmessagestatus7) | Yes  | Status.          |
2293
2294## UpdateSimMessageOptions<sup>7+</sup>
2295
2296Defines the updating SIM message options.
2297
2298**System API**: This is a system API.
2299
2300**System capability**: SystemCapability.Telephony.SmsMms
2301
2302|   Name   | Type                                  | Mandatory| Description          |
2303| --------- | -------------------------------------- | ---- | -------------- |
2304| slotId    | number                                 | Yes  | Card slot ID.        |
2305| msgIndex  | number                                 | Yes  | Message index.      |
2306| newStatus | [SimMessageStatus](#simmessagestatus7) | Yes  | New status.        |
2307| pdu       | string                                 | Yes  | Protocol data unit.  |
2308| smsc      | string                                 | Yes  | Short message service center.|
2309
2310## SimShortMessage<sup>7+</sup>
2311
2312Defines a SIM message.
2313
2314**System API**: This is a system API.
2315
2316**System capability**: SystemCapability.Telephony.SmsMms
2317
2318|       Name      | Type                                  | Mandatory| Description         |
2319| ---------------- | -------------------------------------- | ---- | ------------- |
2320| shortMessage     | [ShortMessage](#shortmessage)          | Yes  | SMS message.       |
2321| simMessageStatus | [SimMessageStatus](#simmessagestatus7) | Yes  | SIM message status.|
2322| indexOnSim       | number                                 | Yes  | SIM card index.    |
2323
2324## MmsDeliveryInd<sup>8+</sup>
2325
2326Defines an MMS message delivery index.
2327
2328**System API**: This is a system API.
2329
2330**System capability**: SystemCapability.Telephony.SmsMms
2331
2332|    Name  | Type                              | Mandatory| Description  |
2333| --------- | ---------------------------------- | ---- | ------ |
2334| messageId | string                             | Yes  | Message ID.|
2335| date      | number                             | Yes  | Date.  |
2336| to        | Array<[MmsAddress](#mmsaddress8)\> | Yes  | Destination address.|
2337| status    | number                             | Yes  | Status.  |
2338| version   | [MmsVersionType](#mmsversiontype8) | Yes  | Version.  |
2339
2340## MmsRespInd<sup>8+</sup>
2341
2342Defines an MMS response index.
2343
2344**System API**: This is a system API.
2345
2346**System capability**: SystemCapability.Telephony.SmsMms
2347
2348|     Name     | Type                              | Mandatory| Description    |
2349| ------------- | ---------------------------------- | ---- | -------- |
2350| transactionId | string                             | Yes  | Event ID.  |
2351| status        | number                             | Yes  | Status.    |
2352| version       | [MmsVersionType](#mmsversiontype8) | Yes  | Version.    |
2353| reportAllowed | [ReportType](#reporttype8)         | No  | Report allowed.|
2354
2355## SmsSegmentsInfo<sup>8+</sup>
2356
2357Defines the SMS message segment information.
2358
2359**System API**: This is a system API.
2360
2361**System capability**: SystemCapability.Telephony.SmsMms
2362
2363|        Name         | Type                                    | Mandatory| Description        |
2364| -------------------- | ---------------------------------------- | ---- | ------------ |
2365| splitCount           | number                                   | Yes  | Split count.    |
2366| encodeCount          | number                                   | Yes  | Encoding count.    |
2367| encodeCountRemaining | number                                   | Yes  | Remaining encoding count.|
2368| scheme               | [SmsEncodingScheme](#smsencodingscheme8) | Yes  | Encoding scheme.|
2369