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<number>, 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<number> | 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<[ShortMessage](#shortmessage)> | 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<number>, 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<number> | 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<[ShortMessage](#shortmessage)> | 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<void>\): 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<void> | 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<void> 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<void> | 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.sendMms<sup>11+</sup> 289 290sendMms\(context: Context, mmsParams: MmsParams, callback: AsyncCallback<void>\): void 291 292Sends an MMS message. This API uses an asynchronous callback to return the result. 293 294**System API**: This is a system API. 295 296**Required permissions**: ohos.permission.SEND_MESSAGES 297 298**System capability**: SystemCapability.Telephony.SmsMms 299 300**Parameters** 301 302| Name | Type | Mandatory| Description | 303| -------- | --------------------------- | ---- | ---------------------------------------- | 304| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| 305| mmsParams | [MmsParams](#mmsparams11) | Yes | Parameters (including the callback) for sending MMS messages. For details, see [MmsParams](#mmsparams11).| 306| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 307 308**Error codes** 309 310For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 311 312| ID| Error Message | 313| -------- | -------------------------------------------- | 314| 201 | Permission denied. | 315| 202 | Non-system applications use system APIs. | 316| 401 | Parameter error. | 317| 8300001 | Invalid parameter value. | 318| 8300002 | Operation failed. Cannot connect to service. | 319| 8300003 | System internal error. | 320| 8300999 | Unknown error code. | 321 322**Example** 323 324FA model: 325 326```ts 327import sms from '@ohos.telephony.sms'; 328import { BusinessError } from '@ohos.base'; 329import common from '@ohos.app.ability.common'; 330 331// Obtain the context. 332import featureAbility from '@ohos.ability.featureAbility'; 333let context: common.BaseContext = featureAbility.getContext(); 334 335// Configure the path for storing PDUs of MMS messages. Such PDUs are sent from the encoding API. 336const sandBoxPath: string = '/data/storage/el2/base/files/'; 337let filePath: string = sandBoxPath + 'SendReq.mms'; 338 339// Options for sending MMS messages (The MMSC is for reference only.) 340let mmsPars: sms.MmsParams = { 341 slotId : 0, 342 mmsc: 'http://mmsc.myuni.com.cn', 343 data: filePath, 344 mmsConfig: { 345 userAgent:'ua', 346 userAgentProfile: 'uaprof' 347 } 348}; 349 350// Call the sendMms API. 351sms.sendMms(context, mmsPars, async(err: BusinessError) =>{ 352 if (err) { 353 console.error(`sendMms fail, err : ${JSON.stringify(err)}`); 354 return; 355 } 356 console.log(`sendMms Success`); 357}) 358``` 359 360Stage model: 361 362```ts 363import UIAbility from '@ohos.app.ability.UIAbility'; 364import sms from '@ohos.telephony.sms'; 365import { BusinessError } from '@ohos.base'; 366import window from '@ohos.window'; 367 368// Configure the path for storing PDUs of MMS messages. Such PDUs are sent from the encoding API. 369const sandBoxPath = '/data/storage/el2/base/files/'; 370let filePath = sandBoxPath + 'SendReq.mms'; 371 372// Configure the MMS user agent and profile. The default values are ua an uaprof, respectively. The configuration is subject to the carrier's requirements. 373let mmsConf: sms.MmsConfig = { 374 userAgent:'ua', 375 userAgentProfile: 'uaprof' 376}; 377 378// Options for sending MMS messages (The MMSC is for reference only.) 379let mmsPars: sms.MmsParams = { 380 slotId : 0, 381 mmsc: 'http://mmsc.myuni.com.cn', 382 data: filePath, 383 mmsConfig: mmsConf 384}; 385 386class EntryAbility extends UIAbility { 387 onWindowStageCreate(windowStage: window.WindowStage) { 388 sms.sendMms(this.context, mmsPars, async(err: BusinessError) =>{ 389 if (err) { 390 console.error(`sendMms fail, err : ${JSON.stringify(err)}`); 391 return; 392 } 393 console.log(`sendMms Success`); 394 }) 395 } 396} 397``` 398 399## sms.sendMms<sup>11+</sup> 400 401sendMms\(context: Context, mmsParams: MmsParams\): Promise<void> 402 403Sends an MMS message. This API uses a promise to return the result. 404 405**System API**: This is a system API. 406 407**Required permissions**: ohos.permission.SEND_MESSAGES 408 409**System capability**: SystemCapability.Telephony.SmsMms 410 411**Parameters** 412 413| Name | Type | Mandatory| Description | 414| -------- | --------------------------- | ---- | ---------------------------------------- | 415| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| 416| mmsParams | [MmsParams](#mmsparams11) | Yes | Parameters (including the callback) for sending MMS messages. For details, see [MmsParams](#mmsparams11).| 417 418**Return value** 419 420| Type | Description | 421| --------------- | ------------------------------------------------------------ | 422| Promise<void> | Promise used to return the result.| 423 424**Error codes** 425 426For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 427 428| ID| Error Message | 429| -------- | -------------------------------------------- | 430| 201 | Permission denied. | 431| 202 | Non-system applications use system APIs. | 432| 401 | Parameter error. | 433| 8300001 | Invalid parameter value. | 434| 8300002 | Operation failed. Cannot connect to service. | 435| 8300003 | System internal error. | 436| 8300999 | Unknown error code. | 437 438**Example** 439 440FA model: 441 442```ts 443import sms from '@ohos.telephony.sms'; 444import { BusinessError } from '@ohos.base'; 445import common from '@ohos.app.ability.common'; 446// Obtain the context. 447import featureAbility from '@ohos.ability.featureAbility'; 448let context: common.BaseContext = featureAbility.getContext(); 449 450// Configure the path for storing PDUs of MMS messages. Such PDUs are sent from the encoding API. 451const sandBoxPath: string = '/data/storage/el2/base/files/'; 452let filePath: string = sandBoxPath + 'SendReq.mms'; 453 454// Options for sending MMS messages (The MMSC is for reference only.) 455let mmsPars: sms.MmsParams = { 456 slotId: 0, 457 mmsc: 'http://mmsc.myuni.com.cn', 458 data: filePath, 459 mmsConfig: { 460 userAgent:'ua', 461 userAgentProfile: 'uaprof' 462 } 463}; 464 465// Call the sendMms API. 466let promise = sms.sendMms(context, mmsPars); 467promise.then(() => { 468 console.log(`sendMms success`); 469}).catch((err: BusinessError) => { 470 console.error(`sendMms failed, promise: err->${JSON.stringify(err)}`); 471}); 472``` 473 474Stage model: 475 476```ts 477import UIAbility from '@ohos.app.ability.UIAbility'; 478import sms from '@ohos.telephony.sms'; 479import { BusinessError } from '@ohos.base'; 480import window from '@ohos.window'; 481 482// Configure the path for storing PDUs of MMS messages. Such PDUs are sent from the encoding API. 483const sandBoxPath = '/data/storage/el2/base/files/'; 484let filePath = sandBoxPath + 'SendReq.mms'; 485 486// Configure the MMS user agent and profile. The default values are ua an uaprof, respectively. The configuration is subject to the carrier's requirements. 487let mmsConf: sms.MmsConfig = { 488 userAgent:'ua', 489 userAgentProfile: 'uaprof' 490}; 491 492// Options for sending MMS messages (The MMSC is for reference only.) 493let mmsPars: sms.MmsParams = { 494 slotId : 0, 495 mmsc: 'http://mmsc.myuni.com.cn', 496 data: filePath, 497 mmsConfig: mmsConf 498}; 499 500class EntryAbility extends UIAbility { 501 onWindowStageCreate(windowStage: window.WindowStage) { 502 let promise = sms.sendMms(this.context, mmsPars); 503 promise.then(() => { 504 console.log(`sendMms success`); 505 }).catch((err: BusinessError) => { 506 console.error(`sendMms failed, promise: err->${JSON.stringify(err)}`); 507 }); 508 } 509} 510``` 511 512## sms.downloadMms<sup>11+</sup> 513 514downloadMms\(context: Context, mmsParams: MmsParams, callback: AsyncCallback<void>\): void 515 516Downloads an MMS message. This API uses an asynchronous callback to return the result. 517 518**System API**: This is a system API. 519 520**Required permissions**: ohos.permission.RECEIVE_MMS 521 522**System capability**: SystemCapability.Telephony.SmsMms 523 524**Parameters** 525 526| Name | Type | Mandatory| Description | 527| -------- | --------------------------- | ---- | ---------------------------------------- | 528| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| 529| mmsParams | [MmsParams](#mmsparams) | Yes | Parameters (including the callback) for downloading MMS messages. For details, see [MmsParams](#mmsparams).| 530| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 531 532**Error codes** 533 534For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 535 536| ID| Error Message | 537| -------- | -------------------------------------------- | 538| 201 | Permission denied. | 539| 202 | Non-system applications use system APIs. | 540| 401 | Parameter error. | 541| 8300001 | Invalid parameter value. | 542| 8300002 | Operation failed. Cannot connect to service. | 543| 8300003 | System internal error. | 544| 8300999 | Unknown error code. | 545 546**Example** 547 548FA model: 549 550```ts 551import sms from '@ohos.telephony.sms'; 552import { BusinessError } from '@ohos.base'; 553import common from '@ohos.app.ability.common'; 554// Obtain the context. 555import featureAbility from '@ohos.ability.featureAbility'; 556let context: common.BaseContext = featureAbility.getContext(); 557 558// Configure the path for storing the PDU of the MMS message. 559const sandBoxPath: string = '/data/storage/el2/base/files/'; 560let filePath: string = sandBoxPath + 'RetrieveConf.mms'; 561 562// Parse the MMS URL from the WAP Push message. 563let wapPushUrl: string = 'URL'; 564 565// Configure the parameters (including the callback) for downloading MMS messages. 566let mmsPars: sms.MmsParams = { 567 slotId: 0, 568 mmsc: wapPushUrl, 569 data: filePath, 570 mmsConfig: { 571 userAgent:'ua', 572 userAgentProfile: 'uaprof' 573 } 574}; 575 576// Call the downloadMms API. 577sms.downloadMms(context, mmsPars, async(err: BusinessError) =>{ 578 if (err) { 579 console.error(`downloadMms fail, err : ${JSON.stringify(err)}`); 580 return; 581 } 582 console.log(`downloadMms Success`); 583}) 584``` 585 586Stage model: 587 588```ts 589import UIAbility from '@ohos.app.ability.UIAbility'; 590import mms from '@ohos.telephony.sms'; 591import { BusinessError } from '@ohos.base'; 592import window from '@ohos.window'; 593 594// Configure the path for storing the PDU of the MMS message. 595const sandBoxPath = '/data/storage/el2/base/files/'; 596let filePath = sandBoxPath + 'RetrieveConf.mms'; 597 598// Parse the MMS URL from the WAP Push message. 599let wapPushUrl = 'URL'; 600 601// Configure the MMS user agent and profile. The default values are ua an uaprof, respectively. The configuration is subject to the carrier's requirements. 602let mmsConf: mms.MmsConfig = { 603 userAgent:'ua', 604 userAgentProfile: 'uaprof' 605}; 606 607// Configure the parameters (including the callback) for downloading MMS messages. 608let mmsPars: mms.MmsParams = { 609 slotId : 0, 610 mmsc: wapPushUrl, 611 data: filePath, 612 mmsConfig: mmsConf 613}; 614 615class EntryAbility extends UIAbility { 616 onWindowStageCreate(windowStage: window.WindowStage) { 617 mms.downloadMms(this.context, mmsPars, async(err: BusinessError) =>{ 618 if (err) { 619 console.error(`downloadMms fail, err : ${JSON.stringify(err)}`); 620 return; 621 } 622 console.log(`downloadMms Success`); 623 }); 624 } 625} 626``` 627 628## sms.downloadMms<sup>11+</sup> 629 630downloadMms\(context: Context, mmsParams: MmsParams\): Promise<void> 631 632Sends an MMS message. This API uses a promise to return the result. 633 634**System API**: This is a system API. 635 636**Required permissions**: ohos.permission.RECEIVE_MMS 637 638**System capability**: SystemCapability.Telephony.SmsMms 639 640**Parameters** 641 642| Name | Type | Mandatory| Description | 643| -------- | --------------------------- | ---- | ---------------------------------------- | 644| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| 645| mmsParams | [MmsParams](#mmsparams) | Yes | Parameters (including the callback) for sending MMS messages. For details, see [MmsParams](#mmsparams).| 646 647**Return value** 648 649| Type | Description | 650| --------------- | ------------------------------------------------------------ | 651| Promise<void> | Promise used to return the result.| 652 653**Error codes** 654 655For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 656 657| ID| Error Message | 658| -------- | -------------------------------------------- | 659| 201 | Permission denied. | 660| 202 | Non-system applications use system APIs. | 661| 401 | Parameter error. | 662| 8300001 | Invalid parameter value. | 663| 8300002 | Operation failed. Cannot connect to service. | 664| 8300003 | System internal error. | 665| 8300999 | Unknown error code. | 666 667**Example** 668 669FA model: 670 671```ts 672import sms from '@ohos.telephony.sms'; 673import { BusinessError } from '@ohos.base'; 674import common from '@ohos.app.ability.common'; 675// Obtain the context. 676import featureAbility from '@ohos.ability.featureAbility'; 677let context: common.BaseContext = featureAbility.getContext(); 678 679// Configure the path for storing the PDU of the MMS message. 680const sandBoxPath: string = '/data/storage/el2/base/files/'; 681let filePath: string = sandBoxPath + 'RetrieveConf.mms'; 682 683// Parse the MMS URL from the WAP Push message. 684let wapPushUrl: string = 'URL'; 685 686// Configure the parameters (including the callback) for downloading MMS messages. 687let mmsPars: sms.MmsParams = { 688 slotId: 0, 689 mmsc: wapPushUrl, 690 data: filePath, 691 mmsConfig: { 692 userAgent:'ua', 693 userAgentProfile: 'uaprof' 694 } 695}; 696 697// Call the sendMms API. 698let promise = sms.downloadMms(context, mmsPars); 699promise.then(() => { 700 console.log(`downloadMms success`); 701}).catch((err: BusinessError) => { 702 console.error(`downloadMms failed, promise: err->${JSON.stringify(err)}`); 703}); 704``` 705 706Stage model: 707 708```ts 709import UIAbility from '@ohos.app.ability.UIAbility'; 710import sms from '@ohos.telephony.sms'; 711import { BusinessError } from '@ohos.base'; 712import window from '@ohos.window'; 713 714// Configure the path for storing the PDU of the MMS message. 715const sandBoxPath = '/data/storage/el2/base/files/'; 716let filePath = sandBoxPath + 'RetrieveConf.mms'; 717 718// Parse the MMS URL from the WAP Push message. 719let wapPushUrl = 'URL'; 720 721// Configure the MMS user agent and profile. The default values are ua an uaprof, respectively. The configuration is subject to the carrier's requirements. 722let mmsConf: sms.MmsConfig = { 723 userAgent:'ua', 724 userAgentProfile: 'uaprof' 725}; 726 727// Configure the parameters (including the callback) for downloading MMS messages. 728let mmsPars: sms.MmsParams = { 729 slotId : 0, 730 mmsc: wapPushUrl, 731 data: filePath, 732 mmsConfig: mmsConf 733}; 734 735class EntryAbility extends UIAbility { 736 onWindowStageCreate(windowStage: window.WindowStage) { 737 let promise = sms.downloadMms(this.context, mmsPars); 738 promise.then(() => { 739 console.log(`downloadMms success`); 740 }).catch((err: BusinessError) => { 741 console.error(`downloadMms failed, promise: err->${JSON.stringify(err)}`); 742 }); 743 } 744} 745``` 746 747## sms.getDefaultSmsSlotId<sup>7+</sup> 748 749getDefaultSmsSlotId\(callback: AsyncCallback<number>\): void 750 751Obtains the default slot ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result. 752 753**System capability**: SystemCapability.Telephony.SmsMms 754 755**Parameters** 756 757| Name | Type | Mandatory| Description | 758| -------- | --------------------------- | ---- | ---------------------------------------- | 759| callback | AsyncCallback<number> | Yes | Callback used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2| 760 761**Example** 762 763```ts 764import sms from '@ohos.telephony.sms'; 765import { BusinessError } from '@ohos.base'; 766 767sms.getDefaultSmsSlotId((err: BusinessError, data: number) => { 768 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 769}); 770``` 771 772 773## sms.getDefaultSmsSlotId<sup>7+</sup> 774 775getDefaultSmsSlotId\(\): Promise<number> 776 777Obtains the default slot ID of the SIM card used to send SMS messages. This API uses a promise to return the result. 778 779**System capability**: SystemCapability.Telephony.SmsMms 780 781**Return value** 782 783| Type | Description | 784| --------------- | ------------------------------------------------------------ | 785| Promise<number> | Promise used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2| 786 787**Example** 788 789```ts 790import sms from '@ohos.telephony.sms'; 791import { BusinessError } from '@ohos.base'; 792 793sms.getDefaultSmsSlotId().then((data: number) => { 794 console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); 795}).catch((err: BusinessError) => { 796 console.error(`getDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`); 797}); 798``` 799 800## sms.setDefaultSmsSlotId<sup>7+</sup> 801 802setDefaultSmsSlotId\(slotId: number, callback: AsyncCallback<void>\): void 803 804Sets the default slot ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result. 805 806**System API**: This is a system API. 807 808**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 809 810**System capability**: SystemCapability.Telephony.SmsMms 811 812**Parameters** 813 814| Name | Type | Mandatory| Description | 815| -------- | ------------------------- | ---- | ------------------------------------------------------------ | 816| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.| 817| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 818 819**Error codes** 820 821For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 822 823| ID| Error Message | 824| -------- | -------------------------------------------- | 825| 201 | Permission denied. | 826| 202 | Non-system applications use system APIs. | 827| 401 | Parameter error. | 828| 8300001 | Invalid parameter value. | 829| 8300002 | Operation failed. Cannot connect to service. | 830| 8300003 | System internal error. | 831| 8300004 | Do not have sim card. | 832| 8300999 | Unknown error code. | 833 834**Example** 835 836```ts 837import sms from '@ohos.telephony.sms'; 838import { BusinessError } from '@ohos.base'; 839 840sms.setDefaultSmsSlotId(0, (err: BusinessError) => { 841 console.log(`callback: err->${JSON.stringify(err)}.`); 842}); 843``` 844 845 846## sms.setDefaultSmsSlotId<sup>7+</sup> 847 848setDefaultSmsSlotId\(slotId: number\): Promise<void> 849 850Sets the default slot ID of the SIM card used to send SMS messages. This API uses a promise to return the result. 851 852**System API**: This is a system API. 853 854**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 855 856**System capability**: SystemCapability.Telephony.SmsMms 857 858**Parameters** 859 860| Name| Type | Mandatory| Description | 861| ------ | ------ | ---- | ------------------------------------------------------------ | 862| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.| 863 864**Return value** 865 866| Type | Description | 867| --------------- | ------------------------------- | 868| Promise\<void\> | Promise used to return the result.| 869 870**Error codes** 871 872For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 873 874| ID| Error Message | 875| -------- | -------------------------------------------- | 876| 201 | Permission denied. | 877| 202 | Non-system applications use system APIs. | 878| 401 | Parameter error. | 879| 8300001 | Invalid parameter value. | 880| 8300002 | Operation failed. Cannot connect to service. | 881| 8300003 | System internal error. | 882| 8300004 | Do not have sim card. | 883| 8300999 | Unknown error code. | 884 885**Example** 886 887```ts 888import sms from '@ohos.telephony.sms'; 889import { BusinessError } from '@ohos.base'; 890 891sms.setDefaultSmsSlotId(0).then(() => { 892 console.log(`setDefaultSmsSlotId success.`); 893}).catch((err: BusinessError) => { 894 console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`); 895}); 896``` 897 898## sms.setSmscAddr<sup>7+</sup> 899 900setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback\<void\>\): void 901 902Sets the short message service center (SMSC) address. This API uses an asynchronous callback to return the result. 903 904**System API**: This is a system API. 905 906**Required permissions**: ohos.permission.SET_TELEPHONY_STATE (a system permission) 907 908**System capability**: SystemCapability.Telephony.SmsMms 909 910**Parameters** 911 912| Name | Type | Mandatory| Description | 913| -------- | ------------------------- | ---- | ----------------------------------------- | 914| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 915| smscAddr | string | Yes | SMSC address. | 916| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 917 918**Error codes** 919 920For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 921 922| ID| Error Message | 923| -------- | -------------------------------------------- | 924| 201 | Permission denied. | 925| 202 | Non-system applications use system APIs. | 926| 401 | Parameter error. | 927| 8300001 | Invalid parameter value. | 928| 8300002 | Operation failed. Cannot connect to service. | 929| 8300003 | System internal error. | 930| 8300999 | Unknown error code. | 931 932**Example** 933 934```ts 935import sms from '@ohos.telephony.sms'; 936import { BusinessError } from '@ohos.base'; 937 938let slotId: number = 0; 939let smscAddr: string = '+861xxxxxxxxxx'; 940sms.setSmscAddr(slotId, smscAddr, (err: BusinessError) => { 941 console.log(`callback: err->${JSON.stringify(err)}`); 942}); 943``` 944 945 946## sms.setSmscAddr<sup>7+</sup> 947 948setSmscAddr\(slotId: number, smscAddr: string\): Promise\<void\> 949 950Sets the SMSC address. This API uses a promise to return the result. 951 952**System API**: This is a system API. 953 954**Required permissions**: ohos.permission.SET_TELEPHONY_STATE (a system permission) 955 956**System capability**: SystemCapability.Telephony.SmsMms 957 958**Parameters** 959 960| Name | Type | Mandatory| Description | 961| -------- | ------ | ---- | ----------------------------------------- | 962| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 963| smscAddr | string | Yes | SMSC address. | 964 965**Return value** 966 967| Type | Description | 968| ------------------- | ------------------------------- | 969| Promise<void> | Promise used to return the result.| 970 971**Error codes** 972 973For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 974 975| ID| Error Message | 976| -------- | -------------------------------------------- | 977| 201 | Permission denied. | 978| 202 | Non-system applications use system APIs. | 979| 401 | Parameter error. | 980| 8300001 | Invalid parameter value. | 981| 8300002 | Operation failed. Cannot connect to service. | 982| 8300003 | System internal error. | 983| 8300999 | Unknown error code. | 984 985**Example** 986 987```ts 988import sms from '@ohos.telephony.sms'; 989import { BusinessError } from '@ohos.base'; 990 991let slotId: number = 0; 992let smscAddr: string = '+861xxxxxxxxxx'; 993sms.setSmscAddr(slotId, smscAddr).then(() => { 994 console.log(`setSmscAddr success.`); 995}).catch((err: BusinessError) => { 996 console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`); 997}); 998``` 999 1000 1001## sms.getSmscAddr<sup>7+</sup> 1002 1003getSmscAddr\(slotId: number, callback: AsyncCallback\<string\>\): void 1004 1005Obtains the SMSC address. This API uses an asynchronous callback to return the result. 1006 1007**System API**: This is a system API. 1008 1009**Required permissions**: ohos.permission.GET_TELEPHONY_STATE (a system permission) 1010 1011**System capability**: SystemCapability.Telephony.SmsMms 1012 1013**Parameters** 1014 1015| Name | Type | Mandatory| Description | 1016| -------- | --------------------------- | ---- | ----------------------------------------- | 1017| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 1018| callback | AsyncCallback<string> | Yes | Callback used to return the result. | 1019 1020**Error codes** 1021 1022For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1023 1024| ID| Error Message | 1025| -------- | -------------------------------------------- | 1026| 201 | Permission denied. | 1027| 202 | Non-system applications use system APIs. | 1028| 401 | Parameter error. | 1029| 8300001 | Invalid parameter value. | 1030| 8300002 | Operation failed. Cannot connect to service. | 1031| 8300003 | System internal error. | 1032| 8300999 | Unknown error code. | 1033 1034**Example** 1035 1036```ts 1037import sms from '@ohos.telephony.sms'; 1038import { BusinessError } from '@ohos.base'; 1039 1040let slotId: number = 0; 1041sms.getSmscAddr(slotId, (err: BusinessError, data: string) => { 1042 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1043}); 1044``` 1045 1046 1047## sms.getSmscAddr<sup>7+</sup> 1048 1049getSmscAddr\(slotId: number\): Promise\<string\> 1050 1051Obtains the SMSC address. This API uses a promise to return the result. 1052 1053**System API**: This is a system API. 1054 1055**Required permissions**: ohos.permission.GET_TELEPHONY_STATE (a system permission) 1056 1057**System capability**: SystemCapability.Telephony.SmsMms 1058 1059**Parameters** 1060 1061| Name| Type | Mandatory| Description | 1062| ------ | ------ | ---- | ----------------------------------------- | 1063| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 1064 1065**Return value** 1066 1067| Type | Description | 1068| --------------------- | --------------------------------------------- | 1069| Promise<string> | Promise used to return the result.| 1070 1071**Error codes** 1072 1073For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1074 1075| ID| Error Message | 1076| -------- | -------------------------------------------- | 1077| 201 | Permission denied. | 1078| 202 | Non-system applications use system APIs. | 1079| 401 | Parameter error. | 1080| 8300001 | Invalid parameter value. | 1081| 8300002 | Operation failed. Cannot connect to service. | 1082| 8300003 | System internal error. | 1083| 8300999 | Unknown error code. | 1084 1085**Example** 1086 1087```ts 1088import sms from '@ohos.telephony.sms'; 1089import { BusinessError } from '@ohos.base'; 1090 1091let slotId: number = 0; 1092sms.getSmscAddr(slotId).then((data: string) => { 1093 console.log(`getSmscAddr success, promise: data->${JSON.stringify(data)}`); 1094}).catch((err: BusinessError) => { 1095 console.error(`getSmscAddr failed, promise: err->${JSON.stringify(err)}`); 1096}); 1097``` 1098 1099## sms.hasSmsCapability<sup>7+</sup> 1100 1101hasSmsCapability\(\): boolean 1102 1103Checks whether the current device can send and receive SMS messages. This API works in synchronous mode. 1104 1105**System capability**: SystemCapability.Telephony.SmsMms 1106 1107**Return value** 1108 1109| Type | Description | 1110| ------- | ------------------------------------------------------------ | 1111| boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.| 1112 1113```ts 1114import sms from '@ohos.telephony.sms'; 1115 1116let result = sms.hasSmsCapability(); 1117console.log(`hasSmsCapability: ${JSON.stringify(result)}`); 1118``` 1119 1120## sms.splitMessage<sup>8+</sup> 1121 1122splitMessage\(content: string, callback: AsyncCallback\<Array\<string\>\>\): void 1123 1124Splits an SMS message into multiple segments. This API uses an asynchronous callback to return the result. 1125 1126**System API**: This is a system API. 1127 1128**Required permissions**: ohos.permission.SEND_MESSAGES 1129 1130**System capability**: SystemCapability.Telephony.SmsMms 1131 1132**Parameters** 1133 1134| Name | Type | Mandatory| Description | 1135| -------- | ----------------------------- | ---- | ----------------------------- | 1136| content | string | Yes | SMS message content. The value cannot be null.| 1137| callback | AsyncCallback<Array<string\>> | Yes | Callback used to return the result.| 1138 1139**Error codes** 1140 1141For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1142 1143| ID| Error Message | 1144| -------- | -------------------------------------------- | 1145| 201 | Permission denied. | 1146| 202 | Non-system applications use system APIs. | 1147| 401 | Parameter error. | 1148| 8300001 | Invalid parameter value. | 1149| 8300002 | Operation failed. Cannot connect to service. | 1150| 8300003 | System internal error. | 1151| 8300999 | Unknown error code. | 1152 1153**Example** 1154 1155```ts 1156import sms from '@ohos.telephony.sms'; 1157import { BusinessError } from '@ohos.base'; 1158 1159let content: string = "long message"; 1160sms.splitMessage(content, (err: BusinessError, data: string[]) => { 1161 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1162}); 1163``` 1164 1165 1166## sms.splitMessage<sup>8+</sup> 1167 1168splitMessage\(content: string\): Promise\<Array\<string\>\> 1169 1170Splits an SMS message into multiple segments. This API uses a promise to return the result. 1171 1172**System API**: This is a system API. 1173 1174**Required permissions**: ohos.permission.SEND_MESSAGES 1175 1176**System capability**: SystemCapability.Telephony.SmsMms 1177 1178**Parameters** 1179 1180| Name | Type | Mandatory| Description | 1181| ------- | ------ | ---- | ---------------------------- | 1182| content | string | Yes | SMS message content. The value cannot be null.| 1183 1184**Return value** 1185 1186| Type | Description | 1187| ----------------------- | ----------------------------------- | 1188| Promise<Array<string\>> | Promise used to return the result.| 1189 1190**Error codes** 1191 1192For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1193 1194| ID| Error Message | 1195| -------- | -------------------------------------------- | 1196| 201 | Permission denied. | 1197| 202 | Non-system applications use system APIs. | 1198| 401 | Parameter error. | 1199| 8300001 | Invalid parameter value. | 1200| 8300002 | Operation failed. Cannot connect to service. | 1201| 8300003 | System internal error. | 1202| 8300999 | Unknown error code. | 1203 1204**Example** 1205 1206```ts 1207import sms from '@ohos.telephony.sms'; 1208import { BusinessError } from '@ohos.base'; 1209 1210let content: string = "long message"; 1211let promise = sms.splitMessage(content); 1212promise.then((data: string[]) => { 1213 console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`); 1214}).catch((err: BusinessError) => { 1215 console.error(`splitMessage failed, promise: err->${JSON.stringify(err)}`); 1216}); 1217``` 1218 1219## sms.addSimMessage<sup>7+</sup> 1220 1221addSimMessage\(options: SimMessageOptions, callback: AsyncCallback\<void\>\): void 1222 1223Adds 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. 1224 1225**System API**: This is a system API. 1226 1227**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES 1228 1229**System capability**: SystemCapability.Telephony.SmsMms 1230 1231**Parameters** 1232 1233| Name | Type | Mandatory| Description | 1234| -------- | ---------------------------------------- | ---- | --------------- | 1235| options | [SimMessageOptions](#simmessageoptions7) | Yes | SIM message options.| 1236| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1237 1238**Error codes** 1239 1240For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1241 1242| ID| Error Message | 1243| -------- | -------------------------------------------- | 1244| 201 | Permission denied. | 1245| 202 | Non-system applications use system APIs. | 1246| 401 | Parameter error. | 1247| 8300001 | Invalid parameter value. | 1248| 8300002 | Operation failed. Cannot connect to service. | 1249| 8300003 | System internal error. | 1250| 8300999 | Unknown error code. | 1251 1252**Example** 1253 1254```ts 1255import sms from '@ohos.telephony.sms'; 1256import { BusinessError } from '@ohos.base'; 1257 1258let simMessageOptions: sms.SimMessageOptions = { 1259 slotId: 0, 1260 smsc: "test", 1261 pdu: "xxxxxx", 1262 status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ 1263}; 1264sms.addSimMessage(simMessageOptions, (err: BusinessError) => { 1265 console.log(`callback: err->${JSON.stringify(err)}`); 1266}); 1267``` 1268 1269 1270## sms.addSimMessage<sup>7+</sup> 1271 1272addSimMessage\(options: SimMessageOptions\): Promise\<void\> 1273 1274Adds 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. 1275 1276**System API**: This is a system API. 1277 1278**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES 1279 1280**System capability**: SystemCapability.Telephony.SmsMms 1281 1282**Parameters** 1283 1284| Name | Type | Mandatory| Description | 1285| ------- | ---------------------------------------- | ---- | --------------- | 1286| options | [SimMessageOptions](#simmessageoptions7) | Yes | SIM message options.| 1287 1288**Return value** 1289 1290| Type | Description | 1291| ------------------- | ----------------------------- | 1292| Promise<void> | Promise used to return the result.| 1293 1294**Error codes** 1295 1296For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1297 1298| ID| Error Message | 1299| -------- | -------------------------------------------- | 1300| 201 | Permission denied. | 1301| 202 | Non-system applications use system APIs. | 1302| 401 | Parameter error. | 1303| 8300001 | Invalid parameter value. | 1304| 8300002 | Operation failed. Cannot connect to service. | 1305| 8300003 | System internal error. | 1306| 8300999 | Unknown error code. | 1307 1308**Example** 1309 1310```ts 1311import sms from '@ohos.telephony.sms'; 1312import { BusinessError } from '@ohos.base'; 1313 1314let simMessageOptions: sms.SimMessageOptions = { 1315 slotId: 0, 1316 smsc: "test", 1317 pdu: "xxxxxx", 1318 status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ 1319}; 1320sms.addSimMessage(simMessageOptions).then(() => { 1321 console.log(`addSimMessage success.`); 1322}).catch((err: BusinessError) => { 1323 console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`); 1324}); 1325``` 1326 1327## sms.delSimMessage<sup>7+</sup> 1328 1329delSimMessage\(slotId: number, msgIndex: number, callback: AsyncCallback\<void\>\): void 1330 1331Deletes 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. 1332 1333**System API**: This is a system API. 1334 1335**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES 1336 1337**System capability**: SystemCapability.Telephony.SmsMms 1338 1339**Parameters** 1340 1341| Name | Type | Mandatory| Description | 1342| -------- | ------------------------- | ---- | ----------------------------------------- | 1343| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 1344| msgIndex | number | Yes | Message index. | 1345| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1346 1347**Error codes** 1348 1349For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1350 1351| ID| Error Message | 1352| -------- | -------------------------------------------- | 1353| 201 | Permission denied. | 1354| 202 | Non-system applications use system APIs. | 1355| 401 | Parameter error. | 1356| 8300001 | Invalid parameter value. | 1357| 8300002 | Operation failed. Cannot connect to service. | 1358| 8300003 | System internal error. | 1359| 8300999 | Unknown error code. | 1360 1361**Example** 1362 1363```ts 1364import sms from '@ohos.telephony.sms'; 1365import { BusinessError } from '@ohos.base'; 1366 1367let slotId: number = 0; 1368let msgIndex: number = 1; 1369sms.delSimMessage(slotId, msgIndex, (err: BusinessError) => { 1370 console.log(`callback: err->${JSON.stringify(err)}`); 1371}); 1372``` 1373 1374 1375## sms.delSimMessage<sup>7+</sup> 1376 1377delSimMessage\(slotId: number, msgIndex: number\): Promise\<void\> 1378 1379Deletes 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. 1380 1381**System API**: This is a system API. 1382 1383**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES 1384 1385**System capability**: SystemCapability.Telephony.SmsMms 1386 1387**Parameters** 1388 1389| Name | Type | Mandatory| Description | 1390| -------- | ------ | ---- | ----------------------------------------- | 1391| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 1392| msgIndex | number | Yes | Message index. | 1393 1394**Return value** 1395 1396| Type | Description | 1397| ------------------- | ----------------------------- | 1398| Promise<void> | Promise used to return the result.| 1399 1400**Error codes** 1401 1402For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1403 1404| ID| Error Message | 1405| -------- | -------------------------------------------- | 1406| 201 | Permission denied. | 1407| 202 | Non-system applications use system APIs. | 1408| 401 | Parameter error. | 1409| 8300001 | Invalid parameter value. | 1410| 8300002 | Operation failed. Cannot connect to service. | 1411| 8300003 | System internal error. | 1412| 8300999 | Unknown error code. | 1413 1414**Example** 1415 1416```ts 1417import sms from '@ohos.telephony.sms'; 1418import { BusinessError } from '@ohos.base'; 1419 1420let slotId: number = 0; 1421let msgIndex: number = 1; 1422let promise = sms.delSimMessage(slotId, msgIndex); 1423promise.then(() => { 1424 console.log(`delSimMessage success.`); 1425}).catch((err: BusinessError) => { 1426 console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`); 1427}); 1428``` 1429 1430## sms.updateSimMessage<sup>7+</sup> 1431 1432updateSimMessage\(options: UpdateSimMessageOptions, callback: AsyncCallback\<void\>\): void 1433 1434Updates a SIM message. This API uses an asynchronous callback to return the result. 1435 1436**System API**: This is a system API. 1437 1438**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES 1439 1440**System capability**: SystemCapability.Telephony.SmsMms 1441 1442**Parameters** 1443 1444| Name | Type | Mandatory| Description | 1445| -------- | ---------------------------------------------------- | ---- | ------------------- | 1446| options | [UpdateSimMessageOptions](#updatesimmessageoptions7) | Yes | SIM message updating options.| 1447| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1448 1449**Error codes** 1450 1451For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1452 1453| ID| Error Message | 1454| -------- | -------------------------------------------- | 1455| 201 | Permission denied. | 1456| 202 | Non-system applications use system APIs. | 1457| 401 | Parameter error. | 1458| 8300001 | Invalid parameter value. | 1459| 8300002 | Operation failed. Cannot connect to service. | 1460| 8300003 | System internal error. | 1461| 8300999 | Unknown error code. | 1462 1463**Example** 1464 1465```ts 1466import sms from '@ohos.telephony.sms'; 1467import { BusinessError } from '@ohos.base'; 1468 1469let updateSimMessageOptions: sms.UpdateSimMessageOptions = { 1470 slotId: 0, 1471 msgIndex: 1, 1472 newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE, 1473 pdu: "xxxxxxx", 1474 smsc: "test" 1475}; 1476sms.updateSimMessage(updateSimMessageOptions, (err: BusinessError) => { 1477 console.log(`callback: err->${JSON.stringify(err)}`); 1478}); 1479``` 1480 1481 1482## sms.updateSimMessage<sup>7+</sup> 1483 1484updateSimMessage\(options: UpdateSimMessageOptions\): Promise\<void\> 1485 1486Updates a SIM message. This API uses a promise to return the result. 1487 1488**System API**: This is a system API. 1489 1490**Required permissions**: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES 1491 1492**System capability**: SystemCapability.Telephony.SmsMms 1493 1494**Parameters** 1495 1496| Name | Type | Mandatory| Description | 1497| ------- | ---------------------------------------------------- | ---- | ------------------- | 1498| options | [UpdateSimMessageOptions](#updatesimmessageoptions7) | Yes | SIM message updating options.| 1499 1500**Return value** 1501 1502| Type | Description | 1503| ------------------- | ----------------------------- | 1504| Promise<void> | Promise used to return the result.| 1505 1506**Error codes** 1507 1508For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1509 1510| ID| Error Message | 1511| -------- | -------------------------------------------- | 1512| 201 | Permission denied. | 1513| 202 | Non-system applications use system APIs. | 1514| 401 | Parameter error. | 1515| 8300001 | Invalid parameter value. | 1516| 8300002 | Operation failed. Cannot connect to service. | 1517| 8300003 | System internal error. | 1518| 8300999 | Unknown error code. | 1519 1520**Example** 1521 1522```ts 1523import sms from '@ohos.telephony.sms'; 1524import { BusinessError } from '@ohos.base'; 1525 1526let updateSimMessageOptions: sms.UpdateSimMessageOptions = { 1527 slotId: 0, 1528 msgIndex: 1, 1529 newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE, 1530 pdu: "xxxxxxx", 1531 smsc: "test" 1532}; 1533let promise = sms.updateSimMessage(updateSimMessageOptions); 1534promise.then(() => { 1535 console.log(`updateSimMessage success.`); 1536}).catch((err: BusinessError) => { 1537 console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`); 1538}); 1539``` 1540 1541## sms.getAllSimMessages<sup>7+</sup> 1542 1543getAllSimMessages\(slotId: number, callback: AsyncCallback\<Array\<SimShortMessage\>\>\): void 1544 1545Obtains all SIM card messages. This API uses an asynchronous callback to return the result. 1546 1547**System API**: This is a system API. 1548 1549**Required permissions**: ohos.permission.RECEIVE_SMS 1550 1551**System capability**: SystemCapability.Telephony.SmsMms 1552 1553**Parameters** 1554 1555| Name | Type | Mandatory| Description | 1556| -------- | ----------------------------------------------------------- | ---- | ----------------------------------------- | 1557| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 1558| callback | AsyncCallback<Array<[SimShortMessage](#simshortmessage7)\>> | Yes | Callback used to return the result. | 1559 1560**Error codes** 1561 1562For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1563 1564| ID| Error Message | 1565| -------- | -------------------------------------------- | 1566| 201 | Permission denied. | 1567| 202 | Non-system applications use system APIs. | 1568| 401 | Parameter error. | 1569| 8300001 | Invalid parameter value. | 1570| 8300002 | Operation failed. Cannot connect to service. | 1571| 8300003 | System internal error. | 1572| 8300999 | Unknown error code. | 1573 1574**Example** 1575 1576```ts 1577import sms from '@ohos.telephony.sms'; 1578import { BusinessError } from '@ohos.base'; 1579 1580let slotId: number = 0; 1581sms.getAllSimMessages(slotId, (err: BusinessError, data: sms.SimShortMessage[]) => { 1582 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1583}); 1584``` 1585 1586 1587## sms.getAllSimMessages<sup>7+</sup> 1588 1589getAllSimMessages\(slotId: number\): Promise\<Array\<SimShortMessage\>\> 1590 1591Obtains all SIM card messages. This API uses a promise to return the result. 1592 1593**System API**: This is a system API. 1594 1595**Required permissions**: ohos.permission.RECEIVE_SMS 1596 1597**System capability**: SystemCapability.Telephony.SmsMms 1598 1599**Parameters** 1600 1601| Name| Type | Mandatory| Description | 1602| ------ | ------ | ---- | ----------------------------------------- | 1603| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 1604 1605**Return value** 1606 1607| Type | Description | 1608| ------------------------------------------------------- | ---------------------------------- | 1609| Promise<Array<[SimShortMessage](#simshortmessage7)\>> | Promise used to return the result.| 1610 1611**Error codes** 1612 1613For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1614 1615| ID| Error Message | 1616| -------- | -------------------------------------------- | 1617| 201 | Permission denied. | 1618| 202 | Non-system applications use system APIs. | 1619| 401 | Parameter error. | 1620| 8300001 | Invalid parameter value. | 1621| 8300002 | Operation failed. Cannot connect to service. | 1622| 8300003 | System internal error. | 1623| 8300999 | Unknown error code. | 1624 1625**Example** 1626 1627```ts 1628import sms from '@ohos.telephony.sms'; 1629import { BusinessError } from '@ohos.base'; 1630 1631let slotId: number = 0; 1632let promise = sms.getAllSimMessages(slotId); 1633promise.then((data: sms.SimShortMessage[]) => { 1634 console.log(`getAllSimMessages success, promise: data->${JSON.stringify(data)}`); 1635}).catch((err: BusinessError) => { 1636 console.error(`getAllSimMessages failed, promise: err->${JSON.stringify(err)}`); 1637}); 1638``` 1639 1640## sms.setCBConfig<sup>7+</sup> 1641 1642setCBConfig\(options: CBConfigOptions, callback: AsyncCallback\<void\>\): void 1643 1644Sets the cell broadcast configuration. This API uses an asynchronous callback to return the result. 1645 1646**System API**: This is a system API. 1647 1648**Required permissions**: ohos.permission.RECEIVE_SMS 1649 1650**System capability**: SystemCapability.Telephony.SmsMms 1651 1652**Parameters** 1653 1654| Name | Type | Mandatory| Description | 1655| -------- | ------------------------------------ | ---- | ------------ | 1656| options | [CBConfigOptions](#cbconfigoptions7) | Yes | Cell broadcast configuration options.| 1657| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1658 1659**Error codes** 1660 1661For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1662 1663| ID| Error Message | 1664| -------- | -------------------------------------------- | 1665| 201 | Permission denied. | 1666| 202 | Non-system applications use system APIs. | 1667| 401 | Parameter error. | 1668| 8300001 | Invalid parameter value. | 1669| 8300002 | Operation failed. Cannot connect to service. | 1670| 8300003 | System internal error. | 1671| 8300999 | Unknown error code. | 1672 1673**Example** 1674 1675```ts 1676import sms from '@ohos.telephony.sms'; 1677import { BusinessError } from '@ohos.base'; 1678 1679let cbConfigOptions: sms.CBConfigOptions = { 1680 slotId: 0, 1681 enable: true, 1682 startMessageId: 100, 1683 endMessageId: 200, 1684 ranType: sms.RanType.TYPE_GSM 1685}; 1686sms.setCBConfig(cbConfigOptions, (err: BusinessError) => { 1687 console.log(`callback: err->${JSON.stringify(err)}`); 1688}); 1689``` 1690 1691 1692## sms.setCBConfig<sup>7+</sup> 1693 1694setCBConfig\(options: CBConfigOptions\): Promise\<void\> 1695 1696Sets the cell broadcast configuration. This API uses a promise to return the result. 1697 1698**System API**: This is a system API. 1699 1700**Required permissions**: ohos.permission.RECEIVE_SMS 1701 1702**System capability**: SystemCapability.Telephony.SmsMms 1703 1704**Parameters** 1705 1706| Name | Type | Mandatory| Description | 1707| ------- | ------------------------------------ | ---- | ------------ | 1708| options | [CBConfigOptions](#cbconfigoptions7) | Yes | Cell broadcast configuration options.| 1709 1710**Return value** 1711 1712| Type | Description | 1713| ------------------- | ----------------------------- | 1714| Promise<void> | Promise used to return the result.| 1715 1716**Error codes** 1717 1718For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1719 1720| ID| Error Message | 1721| -------- | -------------------------------------------- | 1722| 201 | Permission denied. | 1723| 202 | Non-system applications use system APIs. | 1724| 401 | Parameter error. | 1725| 8300001 | Invalid parameter value. | 1726| 8300002 | Operation failed. Cannot connect to service. | 1727| 8300003 | System internal error. | 1728| 8300999 | Unknown error code. | 1729 1730**Example** 1731 1732```ts 1733import sms from '@ohos.telephony.sms'; 1734import { BusinessError } from '@ohos.base'; 1735 1736let cbConfigOptions: sms.CBConfigOptions = { 1737 slotId: 0, 1738 enable: true, 1739 startMessageId: 100, 1740 endMessageId: 200, 1741 ranType: sms.RanType.TYPE_GSM 1742}; 1743let promise = sms.setCBConfig(cbConfigOptions); 1744promise.then(() => { 1745 console.log(`setCBConfig success.`); 1746}).catch((err: BusinessError) => { 1747 console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`); 1748}); 1749``` 1750 1751## sms.getSmsSegmentsInfo<sup>8+</sup> 1752 1753getSmsSegmentsInfo\(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback\<SmsSegmentsInfo\>\): void 1754 1755Obtains SMS message segment information. This API uses an asynchronous callback to return the result. 1756 1757**System API**: This is a system API. 1758 1759**System capability**: SystemCapability.Telephony.SmsMms 1760 1761**Parameters** 1762 1763| Name | Type | Mandatory| Description | 1764| --------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | 1765| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 1766| message | string | Yes | SMS message. | 1767| force7bit | boolean | Yes | Whether to use 7-bit coding. | 1768| callback | AsyncCallback<[SmsSegmentsInfo](#smssegmentsinfo8)> | Yes | Callback used to return the result. | 1769 1770**Error codes** 1771 1772For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1773 1774| ID| Error Message | 1775| -------- | -------------------------------------------- | 1776| 202 | Non-system applications use system APIs. | 1777| 401 | Parameter error. | 1778| 8300001 | Invalid parameter value. | 1779| 8300002 | Operation failed. Cannot connect to service. | 1780| 8300003 | System internal error. | 1781| 8300999 | Unknown error code. | 1782 1783**Example** 1784 1785```ts 1786import sms from '@ohos.telephony.sms'; 1787import { BusinessError } from '@ohos.base'; 1788 1789let slotId: number = 0; 1790sms.getSmsSegmentsInfo(slotId, "message", false, (err: BusinessError, data: sms.SmsSegmentsInfo) => { 1791 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1792}); 1793``` 1794 1795 1796## sms.getSmsSegmentsInfo<sup>8+</sup> 1797 1798getSmsSegmentsInfo\(slotId: number, message: string, force7bit: boolean\): Promise\<SmsSegmentsInfo\> 1799 1800Obtains SMS message segment information. This API uses a promise to return the result. 1801 1802**System API**: This is a system API. 1803 1804**System capability**: SystemCapability.Telephony.SmsMms 1805 1806**Parameters** 1807 1808| Name | Type | Mandatory| Description | 1809| --------- | ------- | ---- | ----------------------------------------- | 1810| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 1811| message | string | Yes | SMS message. | 1812| force7bit | boolean | Yes | Whether to use 7-bit coding. | 1813 1814**Return value** 1815 1816| Type | Description | 1817| ------------------------------------------------------- | ----------------------------- | 1818| Promise<[SmsSegmentsInfo](#smssegmentsinfo8)> | Promise used to return the result.| 1819 1820**Error codes** 1821 1822For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1823 1824| ID| Error Message | 1825| -------- | -------------------------------------------- | 1826| 202 | Non-system applications use system APIs. | 1827| 401 | Parameter error. | 1828| 8300001 | Invalid parameter value. | 1829| 8300002 | Operation failed. Cannot connect to service. | 1830| 8300003 | System internal error. | 1831| 8300999 | Unknown error code. | 1832 1833**Example** 1834 1835```ts 1836import sms from '@ohos.telephony.sms'; 1837import { BusinessError } from '@ohos.base'; 1838 1839let slotId: number = 0; 1840let promise = sms.getSmsSegmentsInfo(slotId, "message", false); 1841promise.then((data: sms.SmsSegmentsInfo) => { 1842 console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`); 1843}).catch((err: BusinessError) => { 1844 console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`); 1845}); 1846``` 1847 1848## sms.isImsSmsSupported<sup>8+</sup> 1849 1850isImsSmsSupported\(slotId: number, callback: AsyncCallback\<boolean\>\): void 1851 1852Checks whether SMS is supported on IMS. This API uses an asynchronous callback to return the result. 1853 1854**System API**: This is a system API. 1855 1856**System capability**: SystemCapability.Telephony.SmsMms 1857 1858**Parameters** 1859 1860| Name | Type | Mandatory| Description | 1861| -------- | ---------------------------- | ---- | ---------- | 1862| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| 1863| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| 1864 1865**Error codes** 1866 1867For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1868 1869| ID| Error Message | 1870| -------- | -------------------------------------------- | 1871| 202 | Non-system applications use system APIs. | 1872| 401 | Parameter error. | 1873| 8300001 | Invalid parameter value. | 1874| 8300002 | Operation failed. Cannot connect to service. | 1875| 8300003 | System internal error. | 1876| 8300999 | Unknown error code. | 1877 1878**Example** 1879 1880```ts 1881import sms from '@ohos.telephony.sms'; 1882import { BusinessError } from '@ohos.base'; 1883 1884let slotId: number = 0; 1885sms.isImsSmsSupported(slotId, (err: BusinessError, data: boolean) => { 1886 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1887}); 1888``` 1889 1890 1891## sms.isImsSmsSupported<sup>8+</sup> 1892 1893isImsSmsSupported\(slotId: number\): Promise\<boolean\> 1894 1895Checks whether SMS is supported on IMS. This API uses a promise to return the result. 1896 1897**System API**: This is a system API. 1898 1899**System capability**: SystemCapability.Telephony.SmsMms 1900 1901**Parameters** 1902 1903| Name| Type | Mandatory | Description | 1904| ------ | ------ | ---- | -------------------------------------- | 1905| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 1906 1907**Return value** 1908 1909| Type | Description | 1910| ---------------------- | ----------------------- | 1911| Promise<boolean> | Promise used to return the result.| 1912 1913**Error codes** 1914 1915For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1916 1917| ID| Error Message | 1918| -------- | -------------------------------------------- | 1919| 202 | Non-system applications use system APIs. | 1920| 401 | Parameter error. | 1921| 8300001 | Invalid parameter value. | 1922| 8300002 | Operation failed. Cannot connect to service. | 1923| 8300003 | System internal error. | 1924| 8300999 | Unknown error code. | 1925 1926**Example** 1927 1928```ts 1929import sms from '@ohos.telephony.sms'; 1930import { BusinessError } from '@ohos.base'; 1931 1932let slotId: number = 0; 1933let promise = sms.isImsSmsSupported(slotId); 1934promise.then((data: boolean) => { 1935 console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`); 1936}).catch((err: BusinessError) => { 1937 console.error(`isImsSmsSupported failed, promise: err->${JSON.stringify(err)}`); 1938}); 1939``` 1940 1941## sms.getImsShortMessageFormat<sup>8+</sup> 1942 1943getImsShortMessageFormat\(callback: AsyncCallback\<string\>\): void 1944 1945Obtains the SMS format supported by the IMS, for example, **3gpp**, **3gpp2**, or **unknown**. This API uses an asynchronous callback to return the result. 1946 1947**System API**: This is a system API. 1948 1949**System capability**: SystemCapability.Telephony.SmsMms 1950 1951**Parameters** 1952 1953| Name | Type | Mandatory| Description | 1954| -------- | --------------------------- | ---- | ---------- | 1955| callback | AsyncCallback<string> | Yes | Callback used to return the result.| 1956 1957**Error codes** 1958 1959For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 1960 1961| ID| Error Message | 1962| -------- | -------------------------------------------- | 1963| 202 | Non-system applications use system APIs. | 1964| 401 | Parameter error. | 1965| 8300001 | Invalid parameter value. | 1966| 8300002 | Operation failed. Cannot connect to service. | 1967| 8300003 | System internal error. | 1968| 8300999 | Unknown error code. | 1969 1970**Example** 1971 1972```ts 1973import sms from '@ohos.telephony.sms'; 1974import { BusinessError } from '@ohos.base'; 1975 1976sms.getImsShortMessageFormat((err: BusinessError, data: string) => { 1977 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1978}); 1979``` 1980 1981 1982## sms.getImsShortMessageFormat<sup>8+</sup> 1983 1984getImsShortMessageFormat\(\): Promise\<string\> 1985 1986Obtains the SMS format supported by the IMS, for example, **3gpp**, **3gpp2**, or **unknown**. This API uses a promise to return the result. 1987 1988**System API**: This is a system API. 1989 1990**System capability**: SystemCapability.Telephony.SmsMms 1991 1992**Return value** 1993 1994| Type | Description | 1995| --------------------- | -------------------------- | 1996| Promise<string> | Promise used to return the result. | 1997 1998**Error codes** 1999 2000For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 2001 2002| ID| Error Message | 2003| -------- | -------------------------------------------- | 2004| 202 | Non-system applications use system APIs. | 2005| 8300002 | Operation failed. Cannot connect to service. | 2006| 8300003 | System internal error. | 2007| 8300999 | Unknown error code. | 2008 2009**Example** 2010 2011```ts 2012import sms from '@ohos.telephony.sms'; 2013import { BusinessError } from '@ohos.base'; 2014 2015sms.getImsShortMessageFormat().then((data: string) => { 2016 console.log(`getImsShortMessageFormat success, promise: data->${JSON.stringify(data)}`); 2017}).catch((err: BusinessError) => { 2018 console.error(`getImsShortMessageFormat failed, promise: err->${JSON.stringify(err)}`); 2019}); 2020``` 2021 2022## sms.decodeMms<sup>8+</sup> 2023 2024decodeMms\(mmsFilePathName: string | Array\<number\>, callback: AsyncCallback\<MmsInformation\>\): void 2025 2026Decodes MMS messages. This API uses an asynchronous callback to return the result. 2027 2028**System API**: This is a system API. 2029 2030**System capability**: SystemCapability.Telephony.SmsMms 2031 2032**Parameters** 2033 2034| Name | Type | Mandatory| Description | 2035| --------------- | ------------------------------------------------------- | ---- | -------------- | 2036| mmsFilePathName | string \|Array<number\> | Yes | MMS message file path.| 2037| callback | AsyncCallback<[MmsInformation](#mmsinformation8)> | Yes | Callback used to return the result, which is carried in {@code MmsInformation}. | 2038 2039**Error codes** 2040 2041For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 2042 2043| ID| Error Message | 2044| -------- | -------------------------------------------- | 2045| 202 | Non-system applications use system APIs. | 2046| 401 | Parameter error. | 2047| 8300001 | Invalid parameter value. | 2048| 8300002 | Operation failed. Cannot connect to service. | 2049| 8300003 | System internal error. | 2050| 8300999 | Unknown error code. | 2051 2052**Example** 2053 2054```ts 2055import sms from '@ohos.telephony.sms'; 2056import { BusinessError } from '@ohos.base'; 2057 2058let mmsFilePathName: string = "filename"; 2059sms.decodeMms(mmsFilePathName, (err: BusinessError, data: sms.MmsInformation) => { 2060 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2061}); 2062 2063const mmsPdu: Array<number> = [0x8c, 0x80, 0x98, 0x31, 0x00, 0x8d, 0x92, 0x89, 0x09, 0x80, 0x07, 0xea, 0x31, 0x30, 0x30, 0x38, 0x36, 0x00, 0x97, 0x07, 0xea, 0x31, 0x30, 0x30,0x31, 0x30, 0x00, 0x84, 0x74, 0x79, 0x70, 0x65, 0x00, 0x00]; 2064sms.decodeMms(mmsPdu, (err: BusinessError, data: sms.MmsInformation) => { 2065 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2066}); 2067``` 2068 2069 2070## sms.decodeMms<sup>8+</sup> 2071 2072decodeMms\(mmsFilePathName: string | Array\<number\>\): Promise\<MmsInformation\> 2073 2074Decodes MMS messages. This API uses a promise to return the result. 2075 2076**System API**: This is a system API. 2077 2078**System capability**: SystemCapability.Telephony.SmsMms 2079 2080**Parameters** 2081 2082| Name | Type | Mandatory| Description | 2083| --------------- | ----------------------- | ---- | -------------- | 2084| mmsFilePathName | string \|Array<number\> | Yes | MMS message file path.| 2085 2086**Return value** 2087 2088| Type | Description | 2089| --------------------------------------------------------- | --------------------------- | 2090| Promise<<[MmsInformation](#mmsinformation8)>> | Promise used to return the result.| 2091 2092**Error codes** 2093 2094For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 2095 2096| ID| Error Message | 2097| -------- | -------------------------------------------- | 2098| 202 | Non-system applications use system APIs. | 2099| 401 | Parameter error. | 2100| 8300001 | Invalid parameter value. | 2101| 8300002 | Operation failed. Cannot connect to service. | 2102| 8300003 | System internal error. | 2103| 8300999 | Unknown error code. | 2104 2105**Example** 2106 2107```ts 2108import sms from '@ohos.telephony.sms'; 2109import { BusinessError } from '@ohos.base'; 2110 2111let mmsFilePathName: string = "filename"; 2112let promise = sms.decodeMms(mmsFilePathName); 2113promise.then((data: sms.MmsInformation) => { 2114 console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`); 2115}).catch((err: BusinessError) => { 2116 console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`); 2117}); 2118 2119const mmsPdu: Array<number> = [0x8c, 0x80, 0x98, 0x31, 0x00, 0x8d, 0x92, 0x89, 0x09, 0x80, 0x07, 0xea, 0x31, 0x30, 0x30, 0x38, 0x36, 0x00, 0x97, 0x07, 0xea, 0x31, 0x30, 0x30,0x31, 0x30, 0x00, 0x84, 0x74, 0x79, 0x70, 0x65, 0x00, 0x00]; 2120let promiseArr = sms.decodeMms(mmsPdu); 2121promiseArr.then((data: sms.MmsInformation) => { 2122 console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`); 2123}).catch((err: BusinessError) => { 2124 console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`); 2125}); 2126``` 2127 2128## sms.encodeMms<sup>8+</sup> 2129 2130encodeMms\(mms: MmsInformation, callback: AsyncCallback\<Array\<number\>\>\): void 2131 2132MMS message code. This API uses an asynchronous callback to return the result. 2133 2134**System API**: This is a system API. 2135 2136**System capability**: SystemCapability.Telephony.SmsMms 2137 2138**Parameters** 2139 2140| Name | Type | Mandatory| Description | 2141| -------- | ----------------------------------- | ---- | ---------- | 2142| mms | [MmsInformation](#mmsinformation8) | Yes | MMS message information.| 2143| callback | AsyncCallback<Array<number\>> | Yes | Callback used to return the result.| 2144 2145**Error codes** 2146 2147For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 2148 2149| ID| Error Message | 2150| -------- | -------------------------------------------- | 2151| 202 | Non-system applications use system APIs. | 2152| 401 | Parameter error. | 2153| 8300001 | Invalid parameter value. | 2154| 8300002 | Operation failed. Cannot connect to service. | 2155| 8300003 | System internal error. | 2156| 8300999 | Unknown error code. | 2157 2158**Example** 2159 2160```ts 2161import sms from '@ohos.telephony.sms'; 2162import { BusinessError } from '@ohos.base'; 2163 2164let mmsAcknowledgeInd: sms.MmsAcknowledgeInd = { 2165 transactionId: "100", 2166 version: sms.MmsVersionType.MMS_VERSION_1_0, 2167 reportAllowed: sms.ReportType.MMS_YES 2168}; 2169let mmsInformation: sms.MmsInformation = { 2170 messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND, 2171 mmsType: mmsAcknowledgeInd 2172}; 2173sms.encodeMms(mmsInformation, (err: BusinessError, data: number[]) => { 2174 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2175}); 2176``` 2177 2178 2179## sms.encodeMms<sup>8+</sup> 2180 2181encodeMms\(mms: MmsInformation\): Promise\<Array\<number\>\> 2182 2183MMS message code. This API uses a promise to return the result. 2184 2185**System API**: This is a system API. 2186 2187**System capability**: SystemCapability.Telephony.SmsMms 2188 2189**Parameters** 2190 2191| Name| Type | Mandatory| Description | 2192| ------ | ---------------------------------- | ---- | ---------- | 2193| mms | [MmsInformation](#mmsinformation8) | Yes | MMS message information.| 2194 2195**Return value** 2196 2197| Type | Description | 2198| ----------------------------- | ----------------------------------- | 2199| Promise<Array<number\>> | Promise used to return the result.| 2200 2201**Error codes** 2202 2203For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 2204 2205| ID| Error Message | 2206| -------- | -------------------------------------------- | 2207| 202 | Non-system applications use system APIs. | 2208| 401 | Parameter error. | 2209| 8300001 | Invalid parameter value. | 2210| 8300002 | Operation failed. Cannot connect to service. | 2211| 8300003 | System internal error. | 2212| 8300999 | Unknown error code. | 2213 2214**Example** 2215 2216```ts 2217import sms from '@ohos.telephony.sms'; 2218import { BusinessError } from '@ohos.base'; 2219 2220let mmsAcknowledgeInd: sms.MmsAcknowledgeInd = { 2221 transactionId: "100", 2222 version: sms.MmsVersionType.MMS_VERSION_1_0, 2223 reportAllowed: sms.ReportType.MMS_YES 2224}; 2225let mmsInformation: sms.MmsInformation = { 2226 messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND, 2227 mmsType: mmsAcknowledgeInd 2228}; 2229sms.encodeMms(mmsInformation).then((data: number[]) => { 2230 console.log(`encodeMms success, promise: data->${JSON.stringify(data)}`); 2231}).catch((err: BusinessError) => { 2232 console.error(`encodeMms failed, promise: err->${JSON.stringify(err)}`); 2233}); 2234``` 2235 2236## sms.getDefaultSmsSimId<sup>10+</sup> 2237 2238getDefaultSmsSimId\(callback: AsyncCallback<number>\): void 2239 2240Obtains the default ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result. 2241 2242**System capability**: SystemCapability.Telephony.SmsMms 2243 2244**Parameters** 2245 2246| Name | Type | Mandatory| Description | 2247| -------- | --------------------------- | ---- | ---------------------------------------- | 2248| callback | AsyncCallback<number> | Yes | Callback used to return the result.<br>The return value is bound to the SIM card and increases from 1.| 2249 2250**Error codes** 2251 2252For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 2253 2254| ID| Error Message | 2255| -------- | -------------------------------------------- | 2256| 401 | Parameter error. | 2257| 8300001 | Invalid parameter value. | 2258| 8300002 | Operation failed. Cannot connect to service. | 2259| 8300003 | System internal error. | 2260| 8300004 | Do not have sim card. | 2261| 8300999 | Unknown error code. | 2262| 8301001 | SIM card is not activated. | 2263 2264**Example** 2265 2266```ts 2267import sms from '@ohos.telephony.sms'; 2268import { BusinessError } from '@ohos.base'; 2269 2270sms.getDefaultSmsSimId((err: BusinessError, data: number) => { 2271 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2272}); 2273``` 2274 2275 2276## sms.getDefaultSmsSimId<sup>10+</sup> 2277 2278getDefaultSmsSimId\(\): Promise<number> 2279 2280Obtains the default ID of the SIM card used to send SMS messages. This API uses a promise to return the result. 2281 2282**System capability**: SystemCapability.Telephony.SmsMms 2283 2284**Return value** 2285 2286| Type | Description | 2287| --------------- | ------------------------------------------------------------ | 2288| Promise<number> | Promise used to return the result.<br>The return value is bound to the SIM card and increases from 1.| 2289 2290**Error codes** 2291 2292For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). 2293 2294| ID| Error Message | 2295| -------- | -------------------------------------------- | 2296| 8300001 | Invalid parameter value. | 2297| 8300002 | Operation failed. Cannot connect to service. | 2298| 8300003 | System internal error. | 2299| 8300004 | Do not have sim card. | 2300| 8300999 | Unknown error code. | 2301| 8301001 | SIM card is not activated. | 2302 2303**Example** 2304 2305```ts 2306import sms from '@ohos.telephony.sms'; 2307import { BusinessError } from '@ohos.base'; 2308 2309let promise = sms.getDefaultSmsSimId(); 2310promise.then((data: number) => { 2311 console.log(`getDefaultSmsSimId success, promise: data->${JSON.stringify(data)}`); 2312}).catch((err: BusinessError) => { 2313 console.error(`getDefaultSmsSimId failed, promise: err->${JSON.stringify(err)}`); 2314}); 2315``` 2316 2317## ShortMessage 2318 2319Defines an SMS message instance. 2320 2321**System capability**: SystemCapability.Telephony.SmsMms 2322 2323| Name | Type | Mandatory| Description | 2324| ------------------------ | --------------------------------------- | ---- | ------------------------------------------------------------ | 2325| 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. | 2326| isReplaceMessage | boolean | Yes | Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see [3GPP TS 23.040 9.2.3.9](https://www.3gpp.org/ftp/specs/archive/23_series/23.040).| 2327| 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.| 2328| messageClass | [ShortMessageClass](#shortmessageclass) | Yes | Enumerates SMS message types. | 2329| pdu | Array<number> | Yes | PDU in the SMS message. | 2330| protocolId | number | Yes | Protocol identifier used for delivering the SMS message. | 2331| scAddress | string | Yes | SMSC address. | 2332| scTimestamp | number | Yes | SMSC timestamp. | 2333| status | number | Yes | SMS message status sent by the SMSC in the **SMS-STATUS-REPORT** message.| 2334| visibleMessageBody | string | Yes | SMS message body. | 2335| visibleRawAddress | string | Yes | Sender address. | 2336 2337 2338## ShortMessageClass 2339 2340Enumerates SMS message types. 2341 2342**System capability**: SystemCapability.Telephony.SmsMms 2343 2344| Name | Value | Description | 2345| ---------------- | ---- | ---------------------------------------- | 2346| UNKNOWN | 0 | Unknown type. | 2347| INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received. | 2348| OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card. | 2349| SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card.| 2350| FORWARD_MESSAGE | 4 | Message to be forwarded to another device. | 2351 2352 2353## SendMessageOptions 2354 2355Provides the options (including callbacks) for sending SMS messages. For example, you can specify the SMS message type by the optional parameter **content**. 2356 2357**System capability**: SystemCapability.Telephony.SmsMms 2358 2359| Name | Type | Mandatory| Description | 2360| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 2361| slotId | number | Yes | Slot ID of the SIM card used for sending SMS messages. <br>- **0**: card slot 1<br>- **1**: card slot 2 | 2362| destinationHost | string | Yes | Destination address of the SMS message. | 2363| content | string \| Array<number> | 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.| 2364| serviceCenter | string | No | SMSC address. By default, the SMSC address in the SIM card is used. | 2365| destinationPort | number | No | Destination port of the SMS message. This field is mandatory only for a data message. Otherwise, it is optional. | 2366| sendCallback | AsyncCallback<[ISendShortMessageCallback](#isendshortmessagecallback)> | No | Callback used to return the SMS message sending result. For details, see [ISendShortMessageCallback](#isendshortmessagecallback).| 2367| deliveryCallback | AsyncCallback<[IDeliveryShortMessageCallback](#ideliveryshortmessagecallback)> | No | Callback used to return the SMS message delivery report. For details, see [IDeliveryShortMessageCallback](#ideliveryshortmessagecallback).| 2368 2369## MmsParams<sup>11+</sup> 2370 2371Defines the parameters for sending SMS messages. 2372 2373**System API**: This is a system API. 2374 2375**System capability**: SystemCapability.Telephony.SmsMms 2376 2377| Name | Type | Mandatory| Description | 2378| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 2379| slotId<sup>11+</sup> | number | Yes | Slot ID of the SIM card used for sending SMS messages. <br>- **0**: card slot 1<br>- **1**: card slot 2 | 2380| mmsc<sup>11+</sup> | string | Yes | MMSC address. | 2381| data<sup>11+</sup> | string | Yes | MMS PDU address.| 2382| mmsConfig<sup>11+</sup> | MmsConfig | No | MMS configuration file. For details, see [MmsParams](#mmsparams11). | 2383 2384## MmsConfig<sup>11+</sup> 2385 2386MMS configuration file. 2387 2388**System API**: This is a system API. 2389 2390**System capability**: SystemCapability.Telephony.SmsMms 2391 2392| Name | Type | Mandatory| Description | 2393| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 2394| userAgent<sup>11+</sup> | string | Yes | User agent. | 2395| userAgentProfile<sup>11+</sup> | string | Yes | User agent profile. | 2396 2397## ISendShortMessageCallback 2398 2399Provides 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. 2400 2401**System capability**: SystemCapability.Telephony.SmsMms 2402 2403| Name | Type | Mandatory| Description | 2404| ---------- | ------------------------------- | ---- | ----------------------------------------------------------------------------------------- | 2405| 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**.| 2406| result | [SendSmsResult](#sendsmsresult) | Yes | SMS message sending result. | 2407| url | string | Yes | URI for storing the sent SMS message. | 2408 2409 2410## IDeliveryShortMessageCallback 2411 2412Provides the callback for the SMS message delivery report. 2413 2414**System capability**: SystemCapability.Telephony.SmsMms 2415 2416| Name| Type | Mandatory| Description | 2417| ---- | ------------------- | ---- | -------------- | 2418| pdu | Array<number> | Yes | SMS message delivery report.| 2419 2420 2421## SendSmsResult 2422 2423Enumerates SMS message sending results. 2424 2425**System capability**: SystemCapability.Telephony.SmsMms 2426 2427| Name | Value | Description | 2428| ------------------------------------ | ---- | ------------------------------------------------------ | 2429| SEND_SMS_SUCCESS | 0 | The SMS message is sent successfully. | 2430| SEND_SMS_FAILURE_UNKNOWN | 1 | Failed to send the SMS message due to an unknown reason. | 2431| SEND_SMS_FAILURE_RADIO_OFF | 2 | Failed to send the SMS message because the modem is shut down. | 2432| 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.| 2433 2434## MmsInformation<sup>8+</sup> 2435 2436Defines the MMS message information. 2437 2438**System API**: This is a system API. 2439 2440**System capability**: SystemCapability.Telephony.SmsMms 2441 2442| Name | Type | Mandatory| Description | 2443| ----------- | ------------------------------------------------------------ | ---- | ---------- | 2444| messageType | [MessageType](#messagetype8) | Yes | Message type.| 2445| mmsType | [MmsSendReq](#mmssendreq8) \|[MmsSendConf](#mmssendconf8) \|[MmsNotificationInd](#mmsnotificationind8) \|[MmsRespInd](#mmsrespind8) \|[MmsRetrieveConf](#mmsretrieveconf8)\|[MmsAcknowledgeInd](#mmsacknowledgeind8)\|[MmsDeliveryInd](#mmsdeliveryind8)\|[MmsReadOrigInd](#mmsreadorigind8)\|[MmsReadRecInd](#mmsreadrecind8) | Yes | PDU header type.| 2446| attachment | Array<[MmsAttachment](#mmsattachment8)\> | No | Attachment. | 2447 2448## MmsSendReq<sup>8+</sup> 2449 2450Defines an MMS message sending request. 2451 2452**System API**: This is a system API. 2453 2454**System capability**: SystemCapability.Telephony.SmsMms 2455 2456| Name | Type | Mandatory| Description | 2457| ---------------- | ------------------------------------ | ---- | ------------ | 2458| from | [MmsAddress](#mmsaddress8) | Yes | MMS message source. | 2459| transactionId | string | Yes | Transaction ID. | 2460| contentType | string | Yes | Content type. | 2461| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | 2462| to | Array<[MmsAddress](#mmsaddress8)\> | No | Destination address. | 2463| date | number | No | Date. | 2464| cc | Array<[MmsAddress](#mmsaddress8)\> | No | Carbon copy. | 2465| bcc | Array<[MmsAddress](#mmsaddress8)\> | No | Blind carbon copy. | 2466| subject | string | No | Subject. | 2467| messageClass | number | No | Message class. | 2468| expiry | number | No | Expiration. | 2469| priority | [MmsPriorityType](#mmsprioritytype8) | No | Priority. | 2470| senderVisibility | number | No | Sender visibility.| 2471| deliveryReport | number | No | Delivery report. | 2472| readReport | number | No | Read report. | 2473 2474## MmsSendConf<sup>8+</sup> 2475 2476Defines the MMS message sending configuration. 2477 2478**System API**: This is a system API. 2479 2480**System capability**: SystemCapability.Telephony.SmsMms 2481 2482| Name | Type | Mandatory| Description | 2483| ------------- | ---------------------------------- | ---- | -------- | 2484| responseState | number | Yes | Response status.| 2485| transactionId | string | Yes | Transaction ID. | 2486| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | 2487| messageId | string | No | Message ID. | 2488 2489## MmsNotificationInd<sup>8+</sup> 2490 2491Defines an MMS notification index. 2492 2493**System API**: This is a system API. 2494 2495**System capability**: SystemCapability.Telephony.SmsMms 2496 2497| Name | Type | Mandatory| Description | 2498| --------------- | ---------------------------------- | ---- | -------- | 2499| transactionId | string | Yes | Transaction ID. | 2500| messageClass | number | Yes | Message class. | 2501| messageSize | number | Yes | Message size.| 2502| expiry | number | Yes | Expiration. | 2503| contentLocation | string | Yes | Content location.| 2504| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | 2505| from | [MmsAddress](#mmsaddress8) | No | Source address. | 2506| subject | string | No | Subject. | 2507| deliveryReport | number | No | Status report.| 2508| contentClass | number | No | Content class. | 2509 2510## MmsAcknowledgeInd<sup>8+</sup> 2511 2512Defines an MMS confirmation index. 2513 2514**System API**: This is a system API. 2515 2516**System capability**: SystemCapability.Telephony.SmsMms 2517 2518| Name | Type | Mandatory| Description | 2519| ------------- | ---------------------------------- | ---- | -------- | 2520| transactionId | string | Yes | Transaction ID. | 2521| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | 2522| reportAllowed | [ReportType](#reporttype8) | No | Report allowed.| 2523 2524## MmsRetrieveConf<sup>8+</sup> 2525 2526Defines the MMS message retrieval configuration. 2527 2528**System API**: This is a system API. 2529 2530**System capability**: SystemCapability.Telephony.SmsMms 2531 2532| Name | Type | Mandatory| Description | 2533| -------------- | ------------------------------------ | ---- | -------- | 2534| transactionId | string | Yes | Transaction ID. | 2535| messageId | string | Yes | Message ID. | 2536| date | number | Yes | Date. | 2537| contentType | string | Yes | Content type.| 2538| to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Destination address. | 2539| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | 2540| from | [MmsAddress](#mmsaddress8) | No | Source address. | 2541| cc | Array<[MmsAddress](#mmsaddress8)\> | No | Carbon copy. | 2542| subject | string | No | Subject. | 2543| priority | [MmsPriorityType](#mmsprioritytype8) | No | Priority. | 2544| deliveryReport | number | No | Status report.| 2545| readReport | number | No | Read report.| 2546| retrieveStatus | number | No | Retrieval status.| 2547| retrieveText | string | No | Retrieval text.| 2548 2549## MmsReadOrigInd<sup>8+</sup> 2550 2551Defines the original MMS message reading index. 2552 2553**System API**: This is a system API. 2554 2555**System capability**: SystemCapability.Telephony.SmsMms 2556 2557| Name | Type | Mandatory| Description | 2558| ---------- | ---------------------------------- | ---- | -------- | 2559| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | 2560| messageId | string | Yes | Message ID. | 2561| to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Destination address. | 2562| from | [MmsAddress](#mmsaddress8) | Yes | Source address. | 2563| date | number | Yes | Date. | 2564| readStatus | number | Yes | Read status.| 2565 2566## MmsReadRecInd<sup>8+</sup> 2567 2568Defines the MMS message reading index. 2569 2570**System API**: This is a system API. 2571 2572**System capability**: SystemCapability.Telephony.SmsMms 2573 2574| Name | Type | Mandatory| Description | 2575| ---------- | ---------------------------------- | ---- | -------- | 2576| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | 2577| messageId | string | Yes | Message ID. | 2578| to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Destination address. | 2579| from | [MmsAddress](#mmsaddress8) | Yes | Source address. | 2580| readStatus | number | Yes | Read status.| 2581| date | number | No | Date. | 2582 2583## MmsAttachment<sup>8+</sup> 2584 2585Defines the attachment of an MMS message. 2586 2587**System API**: This is a system API. 2588 2589**System capability**: SystemCapability.Telephony.SmsMms 2590 2591| Name | Type | Mandatory| Description | 2592| ----------------------- | ------------------------------------ | ---- | ------------------ | 2593| contentId | string | Yes | Content ID. | 2594| contentLocation | string | Yes | Content location. | 2595| contentDisposition | [DispositionType](#dispositiontype8) | Yes | Content disposition. | 2596| contentTransferEncoding | string | Yes | Encoding for content transfer. | 2597| contentType | string | Yes | Content type. | 2598| isSmil | boolean | Yes | Whether the synchronized multimedia integration language is used.| 2599| path | string | No | Path. | 2600| inBuff | Array<number\> | No | Whether the message is in the buffer. | 2601| fileName | string | No | File name. | 2602| charset | [MmsCharSets](#mmscharsets8) | No | Character set. | 2603 2604## MmsAddress<sup>8+</sup> 2605 2606Defines an MMSC address. 2607 2608**System API**: This is a system API. 2609 2610**System capability**: SystemCapability.Telephony.SmsMms 2611 2612| Name | Type | Mandatory| Description | 2613| ------- | ---------------------------- | ---- | ------ | 2614| address | string | Yes | Network address. | 2615| charset | [MmsCharSets](#mmscharsets8) | Yes | Character set.| 2616 2617## MessageType<sup>8+</sup> 2618 2619Message type. 2620 2621**System API**: This is a system API. 2622 2623**System capability**: SystemCapability.Telephony.SmsMms 2624 2625| Name | Value | Description | 2626| ------------------------- | ---- | -------------------- | 2627| TYPE_MMS_SEND_REQ | 128 | MMS message sending request. | 2628| TYPE_MMS_SEND_CONF | 129 | MMS message sending configuration. | 2629| TYPE_MMS_NOTIFICATION_IND | 130 | MMS notification index. | 2630| TYPE_MMS_RESP_IND | 131 | MMS message response index. | 2631| TYPE_MMS_RETRIEVE_CONF | 132 | MMS message retrieval configuration. | 2632| TYPE_MMS_ACKNOWLEDGE_IND | 133 | MMS message acknowledgement index. | 2633| TYPE_MMS_DELIVERY_IND | 134 | MMS message delivery index. | 2634| TYPE_MMS_READ_REC_IND | 135 | MMS message reading and receiving index.| 2635| TYPE_MMS_READ_ORIG_IND | 136 | Original MMS message reading index.| 2636 2637## MmsPriorityType<sup>8+</sup> 2638 2639Enumerates MMS message priorities. 2640 2641**System API**: This is a system API. 2642 2643**System capability**: SystemCapability.Telephony.SmsMms 2644 2645| Name | Value | Description | 2646| ---------- | ---- | -------------- | 2647| MMS_LOW | 128 | Low priority. | 2648| MMS_NORMAL | 129 | Normal priority.| 2649| MMS_HIGH | 130 | High priority. | 2650 2651## MmsVersionType<sup>8+</sup> 2652 2653Enumerates MMS versions. 2654 2655**System API**: This is a system API. 2656 2657**System capability**: SystemCapability.Telephony.SmsMms 2658 2659| Name | Value | Description | 2660| --------------- | ---- | ----------- | 2661| MMS_VERSION_1_0 | 0x10 | MMS version 1_0.| 2662| MMS_VERSION_1_1 | 0x11 | MMS version 1_1.| 2663| MMS_VERSION_1_2 | 0x12 | MMS version 1_2.| 2664| MMS_VERSION_1_3 | 0x13 | MMS version 1_3.| 2665 2666## MmsCharSets<sup>8+</sup> 2667 2668Enumerates MMS character sets. 2669 2670**System API**: This is a system API. 2671 2672**System capability**: SystemCapability.Telephony.SmsMms 2673 2674| Name | Value | Description | 2675| --------------- | ------ | ------------------- | 2676| BIG5 | 0X07EA | BIG5 format. | 2677| ISO_10646_UCS_2 | 0X03E8 | ISO_10646_UCS_2 format.| 2678| ISO_8859_1 | 0X04 | ISO_8859_1 format. | 2679| ISO_8859_2 | 0X05 | ISO_8859_2 format. | 2680| ISO_8859_3 | 0X06 | ISO_8859_3 format. | 2681| ISO_8859_4 | 0X07 | ISO_8859_4 format. | 2682| ISO_8859_5 | 0X08 | ISO_8859_5 format. | 2683| ISO_8859_6 | 0X09 | ISO_8859_6 format. | 2684| ISO_8859_7 | 0X0A | ISO_8859_7 format. | 2685| ISO_8859_8 | 0X0B | ISO_8859_8 format. | 2686| ISO_8859_9 | 0X0C | ISO_8859_9 format. | 2687| SHIFT_JIS | 0X11 | SHIFT_JIS format. | 2688| US_ASCII | 0X03 | US_ASCII format. | 2689| UTF_8 | 0X6A | UTF_8 format. | 2690 2691## DispositionType<sup>8+</sup> 2692 2693Enumerates disposition types. 2694 2695**System API**: This is a system API. 2696 2697**System capability**: SystemCapability.Telephony.SmsMms 2698 2699| Name | Value | Description | 2700| ---------- | ---- | -------- | 2701| FROM_DATA | 0 | Data source.| 2702| ATTACHMENT | 1 | Attachment. | 2703| INLINE | 2 | Inlining. | 2704 2705## ReportType<sup>8+</sup> 2706 2707Enumerates report types. 2708 2709**System API**: This is a system API. 2710 2711**System capability**: SystemCapability.Telephony.SmsMms 2712 2713| Name | Value | Description| 2714| ------- | ---- | ---- | 2715| MMS_YES | 128 | YES | 2716| MMS_NO | 129 | NO | 2717 2718## CBConfigOptions<sup>7+</sup> 2719 2720Defines the cell broadcast configuration options. 2721 2722**System API**: This is a system API. 2723 2724**System capability**: SystemCapability.Telephony.SmsMms 2725 2726| Name | Type | Mandatory| Description | 2727| -------------- | -------------------- | ---- | ------------ | 2728| slotId | number | Yes | Card slot ID. | 2729| enable | boolean | Yes | Whether to enable cell broadcast. | 2730| startMessageId | number | Yes | Start message ID. | 2731| endMessageId | number | Yes | End message ID. | 2732| ranType | [RanType](#rantype7) | Yes | RAN type.| 2733 2734## SimMessageStatus<sup>7+</sup> 2735 2736Defines the SIM message status. 2737 2738**System API**: This is a system API. 2739 2740**System capability**: SystemCapability.Telephony.SmsMms 2741 2742| Name | Value | Description | 2743| ------------------------- | ---- | --------------------------- | 2744| SIM_MESSAGE_STATUS_FREE | 0 | Free space state of the SIM card. | 2745| SIM_MESSAGE_STATUS_READ | 1 | Read state. | 2746| SIM_MESSAGE_STATUS_UNREAD | 3 | Unread state. | 2747| SIM_MESSAGE_STATUS_SENT | 5 | Storage of sent messages (applicable only to SMS).| 2748| SIM_MESSAGE_STATUS_UNSENT | 7 | Storage of unsent messages (applicable only to SMS).| 2749 2750## RanType<sup>7+</sup> 2751 2752RAN type. 2753 2754**System API**: This is a system API. 2755 2756**System capability**: SystemCapability.Telephony.SmsMms 2757 2758| Name | Value | Description| 2759| --------- | ---- | ---- | 2760| TYPE_GSM | 1 | GSM | 2761| TYPE_CDMA | 2 | CMDA | 2762 2763## SmsEncodingScheme<sup>8+</sup> 2764 2765Enumerates SMS encoding schemes. 2766 2767**System API**: This is a system API. 2768 2769**System capability**: SystemCapability.Telephony.SmsMms 2770 2771| Name | Value | Description | 2772| -------------------- | ---- | ------------ | 2773| SMS_ENCODING_UNKNOWN | 0 | Unknown code.| 2774| SMS_ENCODING_7BIT | 1 | 7-digit code. | 2775| SMS_ENCODING_8BIT | 2 | 8-digit code. | 2776| SMS_ENCODING_16BIT | 3 | 16-digit code.| 2777 2778## SimMessageOptions<sup>7+</sup> 2779 2780Defines the SIM message options. 2781 2782**System API**: This is a system API. 2783 2784**System capability**: SystemCapability.Telephony.SmsMms 2785 2786| Name | Type | Mandatory| Description | 2787| ------ | -------------------------------------- | ---- | -------------- | 2788| slotId | number | Yes | Card slot ID. | 2789| smsc | string | Yes | Short message service center.| 2790| pdu | string | Yes | Protocol data unit. | 2791| status | [SimMessageStatus](#simmessagestatus7) | Yes | Status. | 2792 2793## UpdateSimMessageOptions<sup>7+</sup> 2794 2795Defines the updating SIM message options. 2796 2797**System API**: This is a system API. 2798 2799**System capability**: SystemCapability.Telephony.SmsMms 2800 2801| Name | Type | Mandatory| Description | 2802| --------- | -------------------------------------- | ---- | -------------- | 2803| slotId | number | Yes | Card slot ID. | 2804| msgIndex | number | Yes | Message index. | 2805| newStatus | [SimMessageStatus](#simmessagestatus7) | Yes | New status. | 2806| pdu | string | Yes | Protocol data unit. | 2807| smsc | string | Yes | Short message service center.| 2808 2809## SimShortMessage<sup>7+</sup> 2810 2811Defines a SIM message. 2812 2813**System API**: This is a system API. 2814 2815**System capability**: SystemCapability.Telephony.SmsMms 2816 2817| Name | Type | Mandatory| Description | 2818| ---------------- | -------------------------------------- | ---- | ------------- | 2819| shortMessage | [ShortMessage](#shortmessage) | Yes | SMS message. | 2820| simMessageStatus | [SimMessageStatus](#simmessagestatus7) | Yes | SIM message status.| 2821| indexOnSim | number | Yes | SIM card index. | 2822 2823## MmsDeliveryInd<sup>8+</sup> 2824 2825Defines an MMS message delivery index. 2826 2827**System API**: This is a system API. 2828 2829**System capability**: SystemCapability.Telephony.SmsMms 2830 2831| Name | Type | Mandatory| Description | 2832| --------- | ---------------------------------- | ---- | ------ | 2833| messageId | string | Yes | Message ID.| 2834| date | number | Yes | Date. | 2835| to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Destination address.| 2836| status | number | Yes | Status. | 2837| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | 2838 2839## MmsRespInd<sup>8+</sup> 2840 2841Defines an MMS response index. 2842 2843**System API**: This is a system API. 2844 2845**System capability**: SystemCapability.Telephony.SmsMms 2846 2847| Name | Type | Mandatory| Description | 2848| ------------- | ---------------------------------- | ---- | -------- | 2849| transactionId | string | Yes | Event ID. | 2850| status | number | Yes | Status. | 2851| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | 2852| reportAllowed | [ReportType](#reporttype8) | No | Report allowed.| 2853 2854## SmsSegmentsInfo<sup>8+</sup> 2855 2856Defines the SMS message segment information. 2857 2858**System API**: This is a system API. 2859 2860**System capability**: SystemCapability.Telephony.SmsMms 2861 2862| Name | Type | Mandatory| Description | 2863| -------------------- | ---------------------------------------- | ---- | ------------ | 2864| splitCount | number | Yes | Split count. | 2865| encodeCount | number | Yes | Encoding count. | 2866| encodeCountRemaining | number | Yes | Remaining encoding count.| 2867| scheme | [SmsEncodingScheme](#smsencodingscheme8) | Yes | Encoding scheme.| 2868