1e41f4b71Sopenharmony_ci# @ohos.telephony.sms (短信服务)(系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci短信服务提供了管理短信的一些基础能力,包括发送、下载彩信,设置发送短信的默认SIM卡槽ID,获取、设置短信服务中心(SMSC)地址等。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>**说明:**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci>本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci>当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.telephony.sms (短信服务)](js-apis-sms.md)
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## 导入模块
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci```ts
15e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
16e41f4b71Sopenharmony_ci```
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci## sms.sendMms<sup>11+</sup>
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_cisendMms\(context: Context, mmsParams: MmsParams, callback: AsyncCallback&lt;void&gt;\): void
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci发送彩信。使用callback异步回调。
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SEND_MESSAGES
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci**参数:**
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明                                     |
34e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------------------------------------- |
35e41f4b71Sopenharmony_ci| context | Context          | 是   | 应用上下文。<br>FA模型的应用Context定义见[Context](../apis-ability-kit/js-apis-inner-app-context.md)。<br>Stage模型的应用Context定义见[Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md)。 |
36e41f4b71Sopenharmony_ci| mmsParams | [MmsParams](#mmsparams11) | 是   | 发送彩信的参数和回调,参考[MmsParams](#mmsparams11)。 |
37e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 发送彩信的回调函数。 |
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**错误码:**
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
44e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
45e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
46e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.                           |
47e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
48e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
49e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
50e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
51e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci**示例:**
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ciFA模型示例:
56e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
57e41f4b71Sopenharmony_ci```ts
58e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
59e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
60e41f4b71Sopenharmony_ciimport { common, featureAbility } from '@kit.AbilityKit';
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci// 获取context
63e41f4b71Sopenharmony_cilet context: common.BaseContext = featureAbility.getContext();
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci// 彩信pdu存储路径,pdu来源于编码接口
66e41f4b71Sopenharmony_ciconst sandBoxPath: string = '/data/storage/el2/base/files/';
67e41f4b71Sopenharmony_cilet filePath: string  = sandBoxPath + 'SendReq.mms';
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci// 发送彩信参数(mmsc以联通卡为例)
70e41f4b71Sopenharmony_cilet mmsPars: sms.MmsParams = {
71e41f4b71Sopenharmony_ci  slotId : 0,
72e41f4b71Sopenharmony_ci  mmsc: 'http://mmsc.myuni.com.cn',
73e41f4b71Sopenharmony_ci  data: filePath,
74e41f4b71Sopenharmony_ci  mmsConfig: {
75e41f4b71Sopenharmony_ci   userAgent:'ua',
76e41f4b71Sopenharmony_ci   userAgentProfile: 'uaprof'
77e41f4b71Sopenharmony_ci  }
78e41f4b71Sopenharmony_ci};
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci// 调用发送接口
81e41f4b71Sopenharmony_cisms.sendMms(context, mmsPars, async(err: BusinessError) =>{
82e41f4b71Sopenharmony_ci  if (err) {
83e41f4b71Sopenharmony_ci      console.error(`sendMms fail, err : ${JSON.stringify(err)}`);
84e41f4b71Sopenharmony_ci      return;
85e41f4b71Sopenharmony_ci  }
86e41f4b71Sopenharmony_ci  console.log(`sendMms Success`);
87e41f4b71Sopenharmony_ci})
88e41f4b71Sopenharmony_ci```
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ciStage模型示例:
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci```ts
93e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
94e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
95e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
96e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci// 彩信pdu存储路径,pdu来源于编码接口
99e41f4b71Sopenharmony_ciconst sandBoxPath = '/data/storage/el2/base/files/';
100e41f4b71Sopenharmony_cilet filePath  = sandBoxPath + 'SendReq.mms';
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci// 彩信用户代理、用户代理描述配置。根据运营商要求配置,默认ua,uaprof
103e41f4b71Sopenharmony_cilet mmsConf: sms.MmsConfig = {
104e41f4b71Sopenharmony_ci  userAgent:'ua',
105e41f4b71Sopenharmony_ci  userAgentProfile: 'uaprof'
106e41f4b71Sopenharmony_ci};
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci// 发送彩信参数(mmsc以联通卡为例)
109e41f4b71Sopenharmony_cilet mmsPars: sms.MmsParams = {
110e41f4b71Sopenharmony_ci  slotId : 0,
111e41f4b71Sopenharmony_ci  mmsc: 'http://mmsc.myuni.com.cn',
112e41f4b71Sopenharmony_ci  data: filePath,
113e41f4b71Sopenharmony_ci  mmsConfig: mmsConf
114e41f4b71Sopenharmony_ci};
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ciclass EntryAbility extends UIAbility {
117e41f4b71Sopenharmony_ci    onWindowStageCreate(windowStage: window.WindowStage) {
118e41f4b71Sopenharmony_ci    sms.sendMms(this.context, mmsPars, async(err: BusinessError) =>{
119e41f4b71Sopenharmony_ci        if (err) {
120e41f4b71Sopenharmony_ci            console.error(`sendMms fail, err : ${JSON.stringify(err)}`);
121e41f4b71Sopenharmony_ci            return;
122e41f4b71Sopenharmony_ci        }
123e41f4b71Sopenharmony_ci        console.log(`sendMms Success`);
124e41f4b71Sopenharmony_ci        })
125e41f4b71Sopenharmony_ci    }
126e41f4b71Sopenharmony_ci}
127e41f4b71Sopenharmony_ci```
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci## sms.sendMms<sup>11+</sup>
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_cisendMms\(context: Context, mmsParams: MmsParams\): Promise&lt;void&gt;
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci发送彩信。使用Promise异步回调。
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SEND_MESSAGES
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci**参数:**
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明                                     |
144e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------------------------------------- |
145e41f4b71Sopenharmony_ci| context | Context          | 是   | 应用上下文。<br>FA模型的应用Context定义见[Context](../apis-ability-kit/js-apis-inner-app-context.md)。<br>Stage模型的应用Context定义见[Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md)。 |
146e41f4b71Sopenharmony_ci| mmsParams | [MmsParams](#mmsparams11) | 是   | 发送彩信的参数和回调,参考[MmsParams](#mmsparams11)。 |
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci**返回值:**
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci| 类型            | 说明                                                         |
151e41f4b71Sopenharmony_ci| --------------- | ------------------------------------------------------------ |
152e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 以Promise形式返回发送彩信的结果。 |
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci**错误码:**
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
159e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
160e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
161e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.                           |
162e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
163e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
164e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
165e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
166e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**示例:**
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ciFA模型示例:
171e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
172e41f4b71Sopenharmony_ci```ts
173e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
174e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
175e41f4b71Sopenharmony_ciimport { common, featureAbility } from '@kit.AbilityKit';
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci// 获取context
178e41f4b71Sopenharmony_cilet context: common.BaseContext = featureAbility.getContext();
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci// 彩信pdu存储路径,pdu来源于编码接口
181e41f4b71Sopenharmony_ciconst sandBoxPath: string = '/data/storage/el2/base/files/';
182e41f4b71Sopenharmony_cilet filePath: string = sandBoxPath + 'SendReq.mms';
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci// 发送彩信参数(mmsc以联通卡为例)
185e41f4b71Sopenharmony_cilet mmsPars: sms.MmsParams = {
186e41f4b71Sopenharmony_ci  slotId: 0,
187e41f4b71Sopenharmony_ci  mmsc: 'http://mmsc.myuni.com.cn',
188e41f4b71Sopenharmony_ci  data: filePath,
189e41f4b71Sopenharmony_ci  mmsConfig: {
190e41f4b71Sopenharmony_ci   userAgent:'ua',
191e41f4b71Sopenharmony_ci   userAgentProfile: 'uaprof'
192e41f4b71Sopenharmony_ci  }
193e41f4b71Sopenharmony_ci};
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci// 调用发送接口
196e41f4b71Sopenharmony_cilet promise = sms.sendMms(context, mmsPars);
197e41f4b71Sopenharmony_cipromise.then(() => {
198e41f4b71Sopenharmony_ci    console.log(`sendMms success`);
199e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
200e41f4b71Sopenharmony_ci    console.error(`sendMms failed, promise: err->${JSON.stringify(err)}`);
201e41f4b71Sopenharmony_ci});
202e41f4b71Sopenharmony_ci```
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ciStage模型示例:
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci```ts
207e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
208e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
209e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
210e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci// 彩信pdu存储路径,pdu来源于编码接口
213e41f4b71Sopenharmony_ciconst sandBoxPath = '/data/storage/el2/base/files/';
214e41f4b71Sopenharmony_cilet filePath  = sandBoxPath + 'SendReq.mms';
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci// 彩信用户代理、用户代理描述配置。根据运营商要求配置,默认ua,uaprof
217e41f4b71Sopenharmony_cilet mmsConf: sms.MmsConfig = {
218e41f4b71Sopenharmony_ci  userAgent:'ua',
219e41f4b71Sopenharmony_ci  userAgentProfile: 'uaprof'
220e41f4b71Sopenharmony_ci};
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci// 发送彩信参数(mmsc以联通卡为例)
223e41f4b71Sopenharmony_cilet mmsPars: sms.MmsParams = {
224e41f4b71Sopenharmony_ci  slotId : 0,
225e41f4b71Sopenharmony_ci  mmsc: 'http://mmsc.myuni.com.cn',
226e41f4b71Sopenharmony_ci  data: filePath,
227e41f4b71Sopenharmony_ci  mmsConfig: mmsConf
228e41f4b71Sopenharmony_ci};
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ciclass EntryAbility extends UIAbility {
231e41f4b71Sopenharmony_ci    onWindowStageCreate(windowStage: window.WindowStage) {
232e41f4b71Sopenharmony_ci    let promise = sms.sendMms(this.context, mmsPars);
233e41f4b71Sopenharmony_ci    promise.then(() => {
234e41f4b71Sopenharmony_ci        console.log(`sendMms success`);
235e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
236e41f4b71Sopenharmony_ci        console.error(`sendMms failed, promise: err->${JSON.stringify(err)}`);
237e41f4b71Sopenharmony_ci    });
238e41f4b71Sopenharmony_ci    }
239e41f4b71Sopenharmony_ci}
240e41f4b71Sopenharmony_ci```
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci## sms.downloadMms<sup>11+</sup>
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_cidownloadMms\(context: Context, mmsParams: MmsParams, callback: AsyncCallback&lt;void&gt;\): void
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci下载彩信。使用callback异步回调。
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_MMS
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci**参数:**
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明                                     |
257e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------------------------------------- |
258e41f4b71Sopenharmony_ci| context | Context          | 是   | 应用上下文。<br>FA模型的应用Context定义见[Context](../apis-ability-kit/js-apis-inner-app-context.md)。<br>Stage模型的应用Context定义见[Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md)。 |
259e41f4b71Sopenharmony_ci| mmsParams | [MmsParams](#mmsparams11) | 是   | 下载彩信的参数和回调,参考[MmsParams](#mmsparams11)。 |
260e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 下载彩信的回调函数。 |
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci**错误码:**
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
267e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
268e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
269e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.                           |
270e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
271e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
272e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
273e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
274e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci**示例:**
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ciFA模型示例:
279e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
280e41f4b71Sopenharmony_ci```ts
281e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
282e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
283e41f4b71Sopenharmony_ciimport { common, featureAbility } from '@kit.AbilityKit';
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci// 获取context
286e41f4b71Sopenharmony_cilet context: common.BaseContext = featureAbility.getContext();
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci// 彩信pdu存储路径
289e41f4b71Sopenharmony_ciconst sandBoxPath: string = '/data/storage/el2/base/files/';
290e41f4b71Sopenharmony_cilet filePath: string = sandBoxPath + 'RetrieveConf.mms';
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci// 从WapPush中解析出彩信URL
293e41f4b71Sopenharmony_cilet wapPushUrl: string = 'URL';
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci// 下载彩信参数
296e41f4b71Sopenharmony_cilet mmsPars: sms.MmsParams = {
297e41f4b71Sopenharmony_ci  slotId: 0,
298e41f4b71Sopenharmony_ci  mmsc: wapPushUrl,
299e41f4b71Sopenharmony_ci  data: filePath,
300e41f4b71Sopenharmony_ci  mmsConfig: {
301e41f4b71Sopenharmony_ci   userAgent:'ua',
302e41f4b71Sopenharmony_ci   userAgentProfile: 'uaprof'
303e41f4b71Sopenharmony_ci  }
304e41f4b71Sopenharmony_ci};
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci// 调用下载接口
307e41f4b71Sopenharmony_cisms.downloadMms(context, mmsPars, async(err: BusinessError) =>{
308e41f4b71Sopenharmony_ci  if (err) {
309e41f4b71Sopenharmony_ci      console.error(`downloadMms fail, err : ${JSON.stringify(err)}`);
310e41f4b71Sopenharmony_ci      return;
311e41f4b71Sopenharmony_ci  }
312e41f4b71Sopenharmony_ci  console.log(`downloadMms Success`);
313e41f4b71Sopenharmony_ci})
314e41f4b71Sopenharmony_ci```
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ciStage模型示例:
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci```ts
319e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
320e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
321e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
322e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci// 彩信pdu存储路径
325e41f4b71Sopenharmony_ciconst sandBoxPath = '/data/storage/el2/base/files/';
326e41f4b71Sopenharmony_cilet filePath  = sandBoxPath + 'RetrieveConf.mms';
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci// 从WapPush中解析出彩信URL
329e41f4b71Sopenharmony_cilet wapPushUrl  = 'URL';
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci// 彩信用户代理、用户代理描述配置。根据运营商要求配置,默认ua,uaprof
332e41f4b71Sopenharmony_cilet mmsConf: sms.MmsConfig = {
333e41f4b71Sopenharmony_ci  userAgent:'ua',
334e41f4b71Sopenharmony_ci  userAgentProfile: 'uaprof'
335e41f4b71Sopenharmony_ci};
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci// 下载彩信参数
338e41f4b71Sopenharmony_cilet mmsPars: sms.MmsParams = {
339e41f4b71Sopenharmony_ci  slotId : 0,
340e41f4b71Sopenharmony_ci  mmsc: wapPushUrl,
341e41f4b71Sopenharmony_ci  data: filePath,
342e41f4b71Sopenharmony_ci  mmsConfig: mmsConf
343e41f4b71Sopenharmony_ci};
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ciclass EntryAbility extends UIAbility {
346e41f4b71Sopenharmony_ci    onWindowStageCreate(windowStage: window.WindowStage) {
347e41f4b71Sopenharmony_ci    sms.downloadMms(this.context, mmsPars, async(err: BusinessError) =>{
348e41f4b71Sopenharmony_ci        if (err) {
349e41f4b71Sopenharmony_ci            console.error(`downloadMms fail, err : ${JSON.stringify(err)}`);
350e41f4b71Sopenharmony_ci            return;
351e41f4b71Sopenharmony_ci        }
352e41f4b71Sopenharmony_ci        console.log(`downloadMms Success`);
353e41f4b71Sopenharmony_ci        });
354e41f4b71Sopenharmony_ci    }
355e41f4b71Sopenharmony_ci}
356e41f4b71Sopenharmony_ci```
357e41f4b71Sopenharmony_ci
358e41f4b71Sopenharmony_ci## sms.downloadMms<sup>11+</sup>
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_cidownloadMms\(context: Context, mmsParams: MmsParams\): Promise&lt;void&gt;
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ci发送彩信。使用Promise异步回调。
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_MMS
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci**参数:**
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明                                     |
373e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------------------------------------- |
374e41f4b71Sopenharmony_ci| context | Context          | 是   | 应用上下文。<br>FA模型的应用Context定义见[Context](../apis-ability-kit/js-apis-inner-app-context.md)。<br>Stage模型的应用Context定义见[Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md)。 |
375e41f4b71Sopenharmony_ci| mmsParams | [MmsParams](#mmsparams11) | 是   | 发送彩信的参数和回调,参考[MmsParams](#mmsparams11)。 |
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci**返回值:**
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci| 类型            | 说明                                                         |
380e41f4b71Sopenharmony_ci| --------------- | ------------------------------------------------------------ |
381e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 以Promise形式返回发送彩信的结果。 |
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ci**错误码:**
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
388e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
389e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
390e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.                           |
391e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
392e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
393e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
394e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
395e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci**示例:**
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ciFA模型示例:
400e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
401e41f4b71Sopenharmony_ci```ts
402e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
403e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
404e41f4b71Sopenharmony_ciimport { common, featureAbility } from '@kit.AbilityKit';
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci// 获取context
407e41f4b71Sopenharmony_cilet context: common.BaseContext = featureAbility.getContext();
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci// 彩信pdu存储路径
410e41f4b71Sopenharmony_ciconst sandBoxPath: string = '/data/storage/el2/base/files/';
411e41f4b71Sopenharmony_cilet filePath: string = sandBoxPath + 'RetrieveConf.mms';
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci// 从WapPush中解析出彩信URL
414e41f4b71Sopenharmony_cilet wapPushUrl: string = 'URL';
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci// 下载彩信参数
417e41f4b71Sopenharmony_cilet mmsPars: sms.MmsParams = {
418e41f4b71Sopenharmony_ci  slotId: 0,
419e41f4b71Sopenharmony_ci  mmsc: wapPushUrl,
420e41f4b71Sopenharmony_ci  data: filePath,
421e41f4b71Sopenharmony_ci  mmsConfig: {
422e41f4b71Sopenharmony_ci   userAgent:'ua',
423e41f4b71Sopenharmony_ci   userAgentProfile: 'uaprof'
424e41f4b71Sopenharmony_ci  }
425e41f4b71Sopenharmony_ci};
426e41f4b71Sopenharmony_ci
427e41f4b71Sopenharmony_ci// 调用发送接口
428e41f4b71Sopenharmony_cilet promise = sms.downloadMms(context, mmsPars);
429e41f4b71Sopenharmony_cipromise.then(() => {
430e41f4b71Sopenharmony_ci    console.log(`downloadMms success`);
431e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
432e41f4b71Sopenharmony_ci    console.error(`downloadMms failed, promise: err->${JSON.stringify(err)}`);
433e41f4b71Sopenharmony_ci});
434e41f4b71Sopenharmony_ci```
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ciStage模型示例:
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci```ts
439e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
440e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
441e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
442e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ci// 彩信pdu存储路径
445e41f4b71Sopenharmony_ciconst sandBoxPath = '/data/storage/el2/base/files/';
446e41f4b71Sopenharmony_cilet filePath  = sandBoxPath + 'RetrieveConf.mms';
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ci// 从WapPush中解析出彩信URL
449e41f4b71Sopenharmony_cilet wapPushUrl  = 'URL';
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci// 彩信用户代理、用户代理描述配置。根据运营商要求配置,默认ua,uaprof
452e41f4b71Sopenharmony_cilet mmsConf: sms.MmsConfig = {
453e41f4b71Sopenharmony_ci  userAgent:'ua',
454e41f4b71Sopenharmony_ci  userAgentProfile: 'uaprof'
455e41f4b71Sopenharmony_ci};
456e41f4b71Sopenharmony_ci
457e41f4b71Sopenharmony_ci// 下载彩信参数
458e41f4b71Sopenharmony_cilet mmsPars: sms.MmsParams = {
459e41f4b71Sopenharmony_ci  slotId : 0,
460e41f4b71Sopenharmony_ci  mmsc: wapPushUrl,
461e41f4b71Sopenharmony_ci  data: filePath,
462e41f4b71Sopenharmony_ci  mmsConfig: mmsConf
463e41f4b71Sopenharmony_ci};
464e41f4b71Sopenharmony_ci
465e41f4b71Sopenharmony_ciclass EntryAbility extends UIAbility {
466e41f4b71Sopenharmony_ci    onWindowStageCreate(windowStage: window.WindowStage) {
467e41f4b71Sopenharmony_ci    let promise = sms.downloadMms(this.context, mmsPars);
468e41f4b71Sopenharmony_ci    promise.then(() => {
469e41f4b71Sopenharmony_ci        console.log(`downloadMms success`);
470e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
471e41f4b71Sopenharmony_ci        console.error(`downloadMms failed, promise: err->${JSON.stringify(err)}`);
472e41f4b71Sopenharmony_ci    });
473e41f4b71Sopenharmony_ci    }
474e41f4b71Sopenharmony_ci}
475e41f4b71Sopenharmony_ci```
476e41f4b71Sopenharmony_ci
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ci## sms.setDefaultSmsSlotId<sup>7+</sup>
479e41f4b71Sopenharmony_ci
480e41f4b71Sopenharmony_cisetDefaultSmsSlotId\(slotId: number, callback: AsyncCallback&lt;void&gt;\): void
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci设置发送短信的默认SIM卡槽ID。使用callback异步回调。
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci**参数:**
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明                                                         |
493e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
494e41f4b71Sopenharmony_ci| slotId   | number                    | 是   | SIM卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2<br/>- -1:清除默认配置 |
495e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 设置发送短信的默认SIM卡槽ID的回调函数。                                                   |
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_ci**错误码:**
498e41f4b71Sopenharmony_ci
499e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
502e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
503e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
504e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
505e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
506e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
507e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
508e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
509e41f4b71Sopenharmony_ci| 8300004  | Do not have sim card.                        |
510e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci**示例:**
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci```ts
515e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
516e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_cisms.setDefaultSmsSlotId(0, (err: BusinessError) => {
519e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}.`);
520e41f4b71Sopenharmony_ci});
521e41f4b71Sopenharmony_ci```
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ci## sms.setDefaultSmsSlotId<sup>7+</sup>
525e41f4b71Sopenharmony_ci
526e41f4b71Sopenharmony_cisetDefaultSmsSlotId\(slotId: number\): Promise&lt;void&gt;
527e41f4b71Sopenharmony_ci
528e41f4b71Sopenharmony_ci设置发送短信的默认SIM卡槽ID。使用Promise异步回调。
529e41f4b71Sopenharmony_ci
530e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
531e41f4b71Sopenharmony_ci
532e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
533e41f4b71Sopenharmony_ci
534e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
535e41f4b71Sopenharmony_ci
536e41f4b71Sopenharmony_ci**参数:**
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                                         |
539e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ |
540e41f4b71Sopenharmony_ci| slotId | number | 是   | SIM卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2<br/>- -1:清除默认配置 |
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci**返回值:**
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci| 类型            | 说明                            |
545e41f4b71Sopenharmony_ci| --------------- | ------------------------------- |
546e41f4b71Sopenharmony_ci| Promise\<void\> | 以Promise形式异步返回设置结果。 |
547e41f4b71Sopenharmony_ci
548e41f4b71Sopenharmony_ci**错误码:**
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
553e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
554e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
555e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
556e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
557e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
558e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
559e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
560e41f4b71Sopenharmony_ci| 8300004  | Do not have sim card.                        |
561e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_ci**示例:**
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_ci```ts
566e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
567e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
568e41f4b71Sopenharmony_ci
569e41f4b71Sopenharmony_cisms.setDefaultSmsSlotId(0).then(() => {
570e41f4b71Sopenharmony_ci    console.log(`setDefaultSmsSlotId success.`);
571e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
572e41f4b71Sopenharmony_ci    console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
573e41f4b71Sopenharmony_ci});
574e41f4b71Sopenharmony_ci```
575e41f4b71Sopenharmony_ci
576e41f4b71Sopenharmony_ci## sms.setSmscAddr<sup>7+</sup>
577e41f4b71Sopenharmony_ci
578e41f4b71Sopenharmony_cisetSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback\<void\>\): void
579e41f4b71Sopenharmony_ci
580e41f4b71Sopenharmony_ci设置短信服务中心(SMSC)地址。使用callback异步回调。
581e41f4b71Sopenharmony_ci
582e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
583e41f4b71Sopenharmony_ci
584e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE,该权限为系统权限
585e41f4b71Sopenharmony_ci
586e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_ci**参数:**
589e41f4b71Sopenharmony_ci
590e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明                                      |
591e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ----------------------------------------- |
592e41f4b71Sopenharmony_ci| slotId   | number                    | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
593e41f4b71Sopenharmony_ci| smscAddr | string                    | 是   | 短信服务中心地址。                        |
594e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 设置短信服务中心(SMSC)地址的回调函数。                                |
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci**错误码:**
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
601e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
602e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
603e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
604e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
605e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
606e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
607e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
608e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
609e41f4b71Sopenharmony_ci
610e41f4b71Sopenharmony_ci**示例:**
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_ci```ts
613e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
614e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_cilet slotId: number = 0;
617e41f4b71Sopenharmony_cilet smscAddr: string = '+861xxxxxxxxxx';
618e41f4b71Sopenharmony_cisms.setSmscAddr(slotId, smscAddr, (err: BusinessError) => {
619e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}`);
620e41f4b71Sopenharmony_ci});
621e41f4b71Sopenharmony_ci```
622e41f4b71Sopenharmony_ci
623e41f4b71Sopenharmony_ci
624e41f4b71Sopenharmony_ci## sms.setSmscAddr<sup>7+</sup>
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_cisetSmscAddr\(slotId: number, smscAddr: string\): Promise\<void\>
627e41f4b71Sopenharmony_ci
628e41f4b71Sopenharmony_ci设置短信服务中心(SMSC)地址。使用Promise异步回调。
629e41f4b71Sopenharmony_ci
630e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
631e41f4b71Sopenharmony_ci
632e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE,该权限为系统权限
633e41f4b71Sopenharmony_ci
634e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
635e41f4b71Sopenharmony_ci
636e41f4b71Sopenharmony_ci**参数:**
637e41f4b71Sopenharmony_ci
638e41f4b71Sopenharmony_ci| 参数名   | 类型   | 必填 | 说明                                      |
639e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ----------------------------------------- |
640e41f4b71Sopenharmony_ci| slotId   | number | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
641e41f4b71Sopenharmony_ci| smscAddr | string | 是   | 短信服务中心地址。                        |
642e41f4b71Sopenharmony_ci
643e41f4b71Sopenharmony_ci**返回值:**
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_ci| 类型                | 说明                            |
646e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
647e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 以Promise形式异步返回设置结果。 |
648e41f4b71Sopenharmony_ci
649e41f4b71Sopenharmony_ci**错误码:**
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
652e41f4b71Sopenharmony_ci
653e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
654e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
655e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
656e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
657e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
658e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
659e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
660e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
661e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ci**示例:**
664e41f4b71Sopenharmony_ci
665e41f4b71Sopenharmony_ci```ts
666e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
667e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
668e41f4b71Sopenharmony_ci
669e41f4b71Sopenharmony_cilet slotId: number = 0;
670e41f4b71Sopenharmony_cilet smscAddr: string = '+861xxxxxxxxxx';
671e41f4b71Sopenharmony_cisms.setSmscAddr(slotId, smscAddr).then(() => {
672e41f4b71Sopenharmony_ci    console.log(`setSmscAddr success.`);
673e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
674e41f4b71Sopenharmony_ci    console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`);
675e41f4b71Sopenharmony_ci});
676e41f4b71Sopenharmony_ci```
677e41f4b71Sopenharmony_ci
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci## sms.getSmscAddr<sup>7+</sup>
680e41f4b71Sopenharmony_ci
681e41f4b71Sopenharmony_cigetSmscAddr\(slotId: number, callback: AsyncCallback\<string\>\): void
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci获取短信服务中心(SMSC)地址。使用callback异步回调。
684e41f4b71Sopenharmony_ci
685e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
686e41f4b71Sopenharmony_ci
687e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.GET_TELEPHONY_STATE,该权限为系统权限
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
690e41f4b71Sopenharmony_ci
691e41f4b71Sopenharmony_ci**参数:**
692e41f4b71Sopenharmony_ci
693e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明                                      |
694e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ----------------------------------------- |
695e41f4b71Sopenharmony_ci| slotId   | number                      | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
696e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;string&gt; | 是   | 指示用于获取SMSC地址的回调函数。                                |
697e41f4b71Sopenharmony_ci
698e41f4b71Sopenharmony_ci**错误码:**
699e41f4b71Sopenharmony_ci
700e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
701e41f4b71Sopenharmony_ci
702e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
703e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
704e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
705e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
706e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
707e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
708e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
709e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
710e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
711e41f4b71Sopenharmony_ci
712e41f4b71Sopenharmony_ci**示例:**
713e41f4b71Sopenharmony_ci
714e41f4b71Sopenharmony_ci```ts
715e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
716e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
717e41f4b71Sopenharmony_ci
718e41f4b71Sopenharmony_cilet slotId: number = 0;
719e41f4b71Sopenharmony_cisms.getSmscAddr(slotId, (err: BusinessError, data: string) => {
720e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
721e41f4b71Sopenharmony_ci});
722e41f4b71Sopenharmony_ci```
723e41f4b71Sopenharmony_ci
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_ci## sms.getSmscAddr<sup>7+</sup>
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_cigetSmscAddr\(slotId: number\): Promise\<string\>
728e41f4b71Sopenharmony_ci
729e41f4b71Sopenharmony_ci获取短信服务中心(SMSC)地址。使用Promise异步回调。
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.GET_TELEPHONY_STATE,该权限为系统权限
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
736e41f4b71Sopenharmony_ci
737e41f4b71Sopenharmony_ci**参数:**
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                      |
740e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ----------------------------------------- |
741e41f4b71Sopenharmony_ci| slotId | number | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
742e41f4b71Sopenharmony_ci
743e41f4b71Sopenharmony_ci**返回值:**
744e41f4b71Sopenharmony_ci
745e41f4b71Sopenharmony_ci| 类型                  | 说明                                          |
746e41f4b71Sopenharmony_ci| --------------------- | --------------------------------------------- |
747e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | 以Promise形式返回获取短信服务中心地址的结果。 |
748e41f4b71Sopenharmony_ci
749e41f4b71Sopenharmony_ci**错误码:**
750e41f4b71Sopenharmony_ci
751e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
752e41f4b71Sopenharmony_ci
753e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
754e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
755e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
756e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
757e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
758e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
759e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
760e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
761e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci**示例:**
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_ci```ts
766e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
767e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
768e41f4b71Sopenharmony_ci
769e41f4b71Sopenharmony_cilet slotId: number = 0;
770e41f4b71Sopenharmony_cisms.getSmscAddr(slotId).then((data: string) => {
771e41f4b71Sopenharmony_ci    console.log(`getSmscAddr success, promise: data->${JSON.stringify(data)}`);
772e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
773e41f4b71Sopenharmony_ci    console.error(`getSmscAddr failed, promise: err->${JSON.stringify(err)}`);
774e41f4b71Sopenharmony_ci});
775e41f4b71Sopenharmony_ci```
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ci
778e41f4b71Sopenharmony_ci## sms.splitMessage<sup>8+</sup>
779e41f4b71Sopenharmony_ci
780e41f4b71Sopenharmony_cisplitMessage\(content: string, callback: AsyncCallback\<Array\<string\>\>\): void
781e41f4b71Sopenharmony_ci
782e41f4b71Sopenharmony_ci将长短信拆分为多个片段。使用callback异步回调。
783e41f4b71Sopenharmony_ci
784e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
785e41f4b71Sopenharmony_ci
786e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SEND_MESSAGES
787e41f4b71Sopenharmony_ci
788e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
789e41f4b71Sopenharmony_ci
790e41f4b71Sopenharmony_ci**参数:**
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_ci| 参数名   | 类型                          | 必填 | 说明                          |
793e41f4b71Sopenharmony_ci| -------- | ----------------------------- | ---- | ----------------------------- |
794e41f4b71Sopenharmony_ci| content  | string                        | 是   | 指示短消息内容,不能为null。 |
795e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<string\>> | 是   | 返回可合并为完整SMS的拆分段列表的回调函数。|
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_ci**错误码:**
798e41f4b71Sopenharmony_ci
799e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
800e41f4b71Sopenharmony_ci
801e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
802e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
803e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
804e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
805e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
806e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
807e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
808e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
809e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_ci**示例:**
812e41f4b71Sopenharmony_ci
813e41f4b71Sopenharmony_ci```ts
814e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
815e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_cilet content: string = "long message";
818e41f4b71Sopenharmony_cisms.splitMessage(content, (err: BusinessError, data: string[]) => {
819e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
820e41f4b71Sopenharmony_ci});
821e41f4b71Sopenharmony_ci```
822e41f4b71Sopenharmony_ci
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ci## sms.splitMessage<sup>8+</sup>
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_cisplitMessage\(content: string\): Promise\<Array\<string\>\>
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_ci将长短信拆分为多个片段。使用Promise异步回调。
829e41f4b71Sopenharmony_ci
830e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SEND_MESSAGES
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
835e41f4b71Sopenharmony_ci
836e41f4b71Sopenharmony_ci**参数:**
837e41f4b71Sopenharmony_ci
838e41f4b71Sopenharmony_ci| 参数名  | 类型   | 必填 | 说明                         |
839e41f4b71Sopenharmony_ci| ------- | ------ | ---- | ---------------------------- |
840e41f4b71Sopenharmony_ci| content | string | 是   | 指示短消息内容,不能为null。 |
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_ci**返回值:**
843e41f4b71Sopenharmony_ci
844e41f4b71Sopenharmony_ci| 类型                    | 说明                                |
845e41f4b71Sopenharmony_ci| ----------------------- | ----------------------------------- |
846e41f4b71Sopenharmony_ci| Promise<Array<string\>> | 以Promise形式返回多个片段的的结果。 |
847e41f4b71Sopenharmony_ci
848e41f4b71Sopenharmony_ci**错误码:**
849e41f4b71Sopenharmony_ci
850e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
851e41f4b71Sopenharmony_ci
852e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
853e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
854e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
855e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
856e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
857e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
858e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
859e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
860e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
861e41f4b71Sopenharmony_ci
862e41f4b71Sopenharmony_ci**示例:**
863e41f4b71Sopenharmony_ci
864e41f4b71Sopenharmony_ci```ts
865e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
866e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
867e41f4b71Sopenharmony_ci
868e41f4b71Sopenharmony_cilet content: string = "long message";
869e41f4b71Sopenharmony_cilet promise = sms.splitMessage(content);
870e41f4b71Sopenharmony_cipromise.then((data: string[]) => {
871e41f4b71Sopenharmony_ci    console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`);
872e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
873e41f4b71Sopenharmony_ci    console.error(`splitMessage failed, promise: err->${JSON.stringify(err)}`);
874e41f4b71Sopenharmony_ci});
875e41f4b71Sopenharmony_ci```
876e41f4b71Sopenharmony_ci
877e41f4b71Sopenharmony_ci## sms.addSimMessage<sup>7+</sup>
878e41f4b71Sopenharmony_ci
879e41f4b71Sopenharmony_ciaddSimMessage\(options: SimMessageOptions, callback: AsyncCallback\<void\>\): void
880e41f4b71Sopenharmony_ci
881e41f4b71Sopenharmony_ci添加SIM卡消息,sim卡消息满,添加报错。使用callback异步回调。
882e41f4b71Sopenharmony_ci
883e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
884e41f4b71Sopenharmony_ci
885e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
886e41f4b71Sopenharmony_ci
887e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
888e41f4b71Sopenharmony_ci
889e41f4b71Sopenharmony_ci**参数:**
890e41f4b71Sopenharmony_ci
891e41f4b71Sopenharmony_ci| 参数名   | 类型                                     | 必填 | 说明            |
892e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | ---- | --------------- |
893e41f4b71Sopenharmony_ci| options  | [SimMessageOptions](#simmessageoptions7) | 是   | SIM卡消息选项。 |
894e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;                | 是   | 添加SIM卡消息的回调函数。 |
895e41f4b71Sopenharmony_ci
896e41f4b71Sopenharmony_ci**错误码:**
897e41f4b71Sopenharmony_ci
898e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
899e41f4b71Sopenharmony_ci
900e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
901e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
902e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
903e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
904e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                           |
905e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
906e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
907e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
908e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
909e41f4b71Sopenharmony_ci
910e41f4b71Sopenharmony_ci**示例:**
911e41f4b71Sopenharmony_ci
912e41f4b71Sopenharmony_ci```ts
913e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
914e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
915e41f4b71Sopenharmony_ci
916e41f4b71Sopenharmony_cilet simMessageOptions: sms.SimMessageOptions = {
917e41f4b71Sopenharmony_ci    slotId: 0,
918e41f4b71Sopenharmony_ci    smsc: "test",
919e41f4b71Sopenharmony_ci    pdu: "xxxxxx",
920e41f4b71Sopenharmony_ci    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
921e41f4b71Sopenharmony_ci};
922e41f4b71Sopenharmony_cisms.addSimMessage(simMessageOptions, (err: BusinessError) => {
923e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}`);
924e41f4b71Sopenharmony_ci});
925e41f4b71Sopenharmony_ci```
926e41f4b71Sopenharmony_ci
927e41f4b71Sopenharmony_ci
928e41f4b71Sopenharmony_ci## sms.addSimMessage<sup>7+</sup>
929e41f4b71Sopenharmony_ci
930e41f4b71Sopenharmony_ciaddSimMessage\(options: SimMessageOptions\): Promise\<void\>
931e41f4b71Sopenharmony_ci
932e41f4b71Sopenharmony_ci添加SIM卡消息,sim卡消息满,添加报错。使用Promise异步回调。
933e41f4b71Sopenharmony_ci
934e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
935e41f4b71Sopenharmony_ci
936e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
937e41f4b71Sopenharmony_ci
938e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
939e41f4b71Sopenharmony_ci
940e41f4b71Sopenharmony_ci**参数:**
941e41f4b71Sopenharmony_ci
942e41f4b71Sopenharmony_ci| 参数名  | 类型                                     | 必填 | 说明            |
943e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | ---- | --------------- |
944e41f4b71Sopenharmony_ci| options | [SimMessageOptions](#simmessageoptions7) | 是   | SIM卡消息选项。 |
945e41f4b71Sopenharmony_ci
946e41f4b71Sopenharmony_ci**返回值:**
947e41f4b71Sopenharmony_ci
948e41f4b71Sopenharmony_ci| 类型                | 说明                          |
949e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
950e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 以Promise形式返回添加的结果。 |
951e41f4b71Sopenharmony_ci
952e41f4b71Sopenharmony_ci**错误码:**
953e41f4b71Sopenharmony_ci
954e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
955e41f4b71Sopenharmony_ci
956e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
957e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
958e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
959e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
960e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                            |
961e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
962e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
963e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
964e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
965e41f4b71Sopenharmony_ci
966e41f4b71Sopenharmony_ci**示例:**
967e41f4b71Sopenharmony_ci
968e41f4b71Sopenharmony_ci```ts
969e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
970e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
971e41f4b71Sopenharmony_ci
972e41f4b71Sopenharmony_cilet simMessageOptions: sms.SimMessageOptions = {
973e41f4b71Sopenharmony_ci    slotId: 0,
974e41f4b71Sopenharmony_ci    smsc: "test",
975e41f4b71Sopenharmony_ci    pdu: "xxxxxx",
976e41f4b71Sopenharmony_ci    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
977e41f4b71Sopenharmony_ci};
978e41f4b71Sopenharmony_cisms.addSimMessage(simMessageOptions).then(() => {
979e41f4b71Sopenharmony_ci    console.log(`addSimMessage success.`);
980e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
981e41f4b71Sopenharmony_ci    console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`);
982e41f4b71Sopenharmony_ci});
983e41f4b71Sopenharmony_ci```
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci## sms.delSimMessage<sup>7+</sup>
986e41f4b71Sopenharmony_ci
987e41f4b71Sopenharmony_cidelSimMessage\(slotId: number, msgIndex: number, callback: AsyncCallback\<void\>\): void
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_ci删除SIM卡消息,msgIndex无效时,删除报错。使用callback异步回调。
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
992e41f4b71Sopenharmony_ci
993e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
994e41f4b71Sopenharmony_ci
995e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
996e41f4b71Sopenharmony_ci
997e41f4b71Sopenharmony_ci**参数:**
998e41f4b71Sopenharmony_ci
999e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明                                      |
1000e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ----------------------------------------- |
1001e41f4b71Sopenharmony_ci| slotId   | number                    | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1002e41f4b71Sopenharmony_ci| msgIndex | number                    | 是   | 消息索引。                                  |
1003e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 删除SIM卡消息的回调函数。  |
1004e41f4b71Sopenharmony_ci
1005e41f4b71Sopenharmony_ci**错误码:**
1006e41f4b71Sopenharmony_ci
1007e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1008e41f4b71Sopenharmony_ci
1009e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
1010e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1011e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
1012e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1013e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
1014e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1015e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1016e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1017e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1018e41f4b71Sopenharmony_ci
1019e41f4b71Sopenharmony_ci**示例:**
1020e41f4b71Sopenharmony_ci
1021e41f4b71Sopenharmony_ci```ts
1022e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1023e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1024e41f4b71Sopenharmony_ci
1025e41f4b71Sopenharmony_cilet slotId: number = 0;
1026e41f4b71Sopenharmony_cilet msgIndex: number = 1;
1027e41f4b71Sopenharmony_cisms.delSimMessage(slotId, msgIndex, (err: BusinessError) => {
1028e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}`);
1029e41f4b71Sopenharmony_ci});
1030e41f4b71Sopenharmony_ci```
1031e41f4b71Sopenharmony_ci
1032e41f4b71Sopenharmony_ci
1033e41f4b71Sopenharmony_ci## sms.delSimMessage<sup>7+</sup>
1034e41f4b71Sopenharmony_ci
1035e41f4b71Sopenharmony_cidelSimMessage\(slotId: number, msgIndex: number\): Promise\<void\>
1036e41f4b71Sopenharmony_ci
1037e41f4b71Sopenharmony_ci删除SIM卡消息,msgIndex无效时,删除报错。使用Promise异步回调。
1038e41f4b71Sopenharmony_ci
1039e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1040e41f4b71Sopenharmony_ci
1041e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
1042e41f4b71Sopenharmony_ci
1043e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1044e41f4b71Sopenharmony_ci
1045e41f4b71Sopenharmony_ci**参数:**
1046e41f4b71Sopenharmony_ci
1047e41f4b71Sopenharmony_ci| 参数名   | 类型   | 必填 | 说明                                      |
1048e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ----------------------------------------- |
1049e41f4b71Sopenharmony_ci| slotId   | number | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1050e41f4b71Sopenharmony_ci| msgIndex | number | 是   | 消息索引。                                  |
1051e41f4b71Sopenharmony_ci
1052e41f4b71Sopenharmony_ci**返回值:**
1053e41f4b71Sopenharmony_ci
1054e41f4b71Sopenharmony_ci| 类型                | 说明                          |
1055e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
1056e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 以Promise形式返回删除的结果。 |
1057e41f4b71Sopenharmony_ci
1058e41f4b71Sopenharmony_ci**错误码:**
1059e41f4b71Sopenharmony_ci
1060e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1061e41f4b71Sopenharmony_ci
1062e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
1063e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1064e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
1065e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1066e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
1067e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1068e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1069e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1070e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1071e41f4b71Sopenharmony_ci
1072e41f4b71Sopenharmony_ci**示例:**
1073e41f4b71Sopenharmony_ci
1074e41f4b71Sopenharmony_ci```ts
1075e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1076e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1077e41f4b71Sopenharmony_ci
1078e41f4b71Sopenharmony_cilet slotId: number = 0;
1079e41f4b71Sopenharmony_cilet msgIndex: number = 1;
1080e41f4b71Sopenharmony_cilet promise = sms.delSimMessage(slotId, msgIndex);
1081e41f4b71Sopenharmony_cipromise.then(() => {
1082e41f4b71Sopenharmony_ci    console.log(`delSimMessage success.`);
1083e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1084e41f4b71Sopenharmony_ci    console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`);
1085e41f4b71Sopenharmony_ci});
1086e41f4b71Sopenharmony_ci```
1087e41f4b71Sopenharmony_ci
1088e41f4b71Sopenharmony_ci## sms.updateSimMessage<sup>7+</sup>
1089e41f4b71Sopenharmony_ci
1090e41f4b71Sopenharmony_ciupdateSimMessage\(options: UpdateSimMessageOptions, callback: AsyncCallback\<void\>\): void
1091e41f4b71Sopenharmony_ci
1092e41f4b71Sopenharmony_ci更新SIM卡消息。使用callback异步回调。
1093e41f4b71Sopenharmony_ci
1094e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1095e41f4b71Sopenharmony_ci
1096e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
1097e41f4b71Sopenharmony_ci
1098e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1099e41f4b71Sopenharmony_ci
1100e41f4b71Sopenharmony_ci**参数:**
1101e41f4b71Sopenharmony_ci
1102e41f4b71Sopenharmony_ci| 参数名   | 类型                                                 | 必填 | 说明                |
1103e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------------- | ---- | ------------------- |
1104e41f4b71Sopenharmony_ci| options  | [UpdateSimMessageOptions](#updatesimmessageoptions7) | 是   | 更新SIM卡消息选项。 |
1105e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;                            | 是   | 更新SIM卡消息的回调函数。 |
1106e41f4b71Sopenharmony_ci
1107e41f4b71Sopenharmony_ci**错误码:**
1108e41f4b71Sopenharmony_ci
1109e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1110e41f4b71Sopenharmony_ci
1111e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
1112e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1113e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
1114e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1115e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                            |
1116e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1117e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1118e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1119e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1120e41f4b71Sopenharmony_ci
1121e41f4b71Sopenharmony_ci**示例:**
1122e41f4b71Sopenharmony_ci
1123e41f4b71Sopenharmony_ci```ts
1124e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1125e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1126e41f4b71Sopenharmony_ci
1127e41f4b71Sopenharmony_cilet updateSimMessageOptions: sms.UpdateSimMessageOptions = {
1128e41f4b71Sopenharmony_ci    slotId: 0,
1129e41f4b71Sopenharmony_ci    msgIndex: 1,
1130e41f4b71Sopenharmony_ci    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
1131e41f4b71Sopenharmony_ci    pdu: "xxxxxxx",
1132e41f4b71Sopenharmony_ci    smsc: "test"
1133e41f4b71Sopenharmony_ci};
1134e41f4b71Sopenharmony_cisms.updateSimMessage(updateSimMessageOptions, (err: BusinessError) => {
1135e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}`);
1136e41f4b71Sopenharmony_ci});
1137e41f4b71Sopenharmony_ci```
1138e41f4b71Sopenharmony_ci
1139e41f4b71Sopenharmony_ci
1140e41f4b71Sopenharmony_ci## sms.updateSimMessage<sup>7+</sup>
1141e41f4b71Sopenharmony_ci
1142e41f4b71Sopenharmony_ciupdateSimMessage\(options: UpdateSimMessageOptions\): Promise\<void\>
1143e41f4b71Sopenharmony_ci
1144e41f4b71Sopenharmony_ci更新SIM卡消息。使用Promise异步回调。
1145e41f4b71Sopenharmony_ci
1146e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1147e41f4b71Sopenharmony_ci
1148e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
1149e41f4b71Sopenharmony_ci
1150e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1151e41f4b71Sopenharmony_ci
1152e41f4b71Sopenharmony_ci**参数:**
1153e41f4b71Sopenharmony_ci
1154e41f4b71Sopenharmony_ci| 参数名  | 类型                                                 | 必填 | 说明                |
1155e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------- | ---- | ------------------- |
1156e41f4b71Sopenharmony_ci| options | [UpdateSimMessageOptions](#updatesimmessageoptions7) | 是   | 更新SIM卡消息选项。 |
1157e41f4b71Sopenharmony_ci
1158e41f4b71Sopenharmony_ci**返回值:**
1159e41f4b71Sopenharmony_ci
1160e41f4b71Sopenharmony_ci| 类型                | 说明                          |
1161e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
1162e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 以Promise形式返回更新的结果。 |
1163e41f4b71Sopenharmony_ci
1164e41f4b71Sopenharmony_ci**错误码:**
1165e41f4b71Sopenharmony_ci
1166e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1167e41f4b71Sopenharmony_ci
1168e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
1169e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1170e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
1171e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1172e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                            |
1173e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1174e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1175e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1176e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1177e41f4b71Sopenharmony_ci
1178e41f4b71Sopenharmony_ci**示例:**
1179e41f4b71Sopenharmony_ci
1180e41f4b71Sopenharmony_ci```ts
1181e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1182e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1183e41f4b71Sopenharmony_ci
1184e41f4b71Sopenharmony_cilet updateSimMessageOptions: sms.UpdateSimMessageOptions = {
1185e41f4b71Sopenharmony_ci    slotId: 0,
1186e41f4b71Sopenharmony_ci    msgIndex: 1,
1187e41f4b71Sopenharmony_ci    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
1188e41f4b71Sopenharmony_ci    pdu: "xxxxxxx",
1189e41f4b71Sopenharmony_ci    smsc: "test"
1190e41f4b71Sopenharmony_ci};
1191e41f4b71Sopenharmony_cilet promise = sms.updateSimMessage(updateSimMessageOptions);
1192e41f4b71Sopenharmony_cipromise.then(() => {
1193e41f4b71Sopenharmony_ci    console.log(`updateSimMessage success.`);
1194e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1195e41f4b71Sopenharmony_ci    console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`);
1196e41f4b71Sopenharmony_ci});
1197e41f4b71Sopenharmony_ci```
1198e41f4b71Sopenharmony_ci
1199e41f4b71Sopenharmony_ci## sms.getAllSimMessages<sup>7+</sup>
1200e41f4b71Sopenharmony_ci
1201e41f4b71Sopenharmony_cigetAllSimMessages\(slotId: number, callback: AsyncCallback\<Array\<SimShortMessage\>\>\): void
1202e41f4b71Sopenharmony_ci
1203e41f4b71Sopenharmony_ci获取所有SIM卡消息。使用callback异步回调。
1204e41f4b71Sopenharmony_ci
1205e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1206e41f4b71Sopenharmony_ci
1207e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_SMS
1208e41f4b71Sopenharmony_ci
1209e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1210e41f4b71Sopenharmony_ci
1211e41f4b71Sopenharmony_ci**参数:**
1212e41f4b71Sopenharmony_ci
1213e41f4b71Sopenharmony_ci| 参数名   | 类型                                                        | 必填 | 说明                                      |
1214e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------------- | ---- | ----------------------------------------- |
1215e41f4b71Sopenharmony_ci| slotId   | number                                                      | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1216e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<[SimShortMessage](#simshortmessage7)\>> | 是   | 获取所有SIM卡消息的回调函数。  |
1217e41f4b71Sopenharmony_ci
1218e41f4b71Sopenharmony_ci**错误码:**
1219e41f4b71Sopenharmony_ci
1220e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1221e41f4b71Sopenharmony_ci
1222e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
1223e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1224e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
1225e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1226e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                         |
1227e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1228e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1229e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1230e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1231e41f4b71Sopenharmony_ci
1232e41f4b71Sopenharmony_ci**示例:**
1233e41f4b71Sopenharmony_ci
1234e41f4b71Sopenharmony_ci```ts
1235e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1236e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1237e41f4b71Sopenharmony_ci
1238e41f4b71Sopenharmony_cilet slotId: number = 0;
1239e41f4b71Sopenharmony_cisms.getAllSimMessages(slotId, (err: BusinessError, data: sms.SimShortMessage[]) => {
1240e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1241e41f4b71Sopenharmony_ci});
1242e41f4b71Sopenharmony_ci```
1243e41f4b71Sopenharmony_ci
1244e41f4b71Sopenharmony_ci
1245e41f4b71Sopenharmony_ci## sms.getAllSimMessages<sup>7+</sup>
1246e41f4b71Sopenharmony_ci
1247e41f4b71Sopenharmony_cigetAllSimMessages\(slotId: number\): Promise\<Array\<SimShortMessage\>\>
1248e41f4b71Sopenharmony_ci
1249e41f4b71Sopenharmony_ci获取所有SIM卡消息。使用Promise异步回调。
1250e41f4b71Sopenharmony_ci
1251e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1252e41f4b71Sopenharmony_ci
1253e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_SMS
1254e41f4b71Sopenharmony_ci
1255e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1256e41f4b71Sopenharmony_ci
1257e41f4b71Sopenharmony_ci**参数:**
1258e41f4b71Sopenharmony_ci
1259e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                      |
1260e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ----------------------------------------- |
1261e41f4b71Sopenharmony_ci| slotId | number | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1262e41f4b71Sopenharmony_ci
1263e41f4b71Sopenharmony_ci**返回值:**
1264e41f4b71Sopenharmony_ci
1265e41f4b71Sopenharmony_ci| 类型                                                    | 说明                               |
1266e41f4b71Sopenharmony_ci| ------------------------------------------------------- | ---------------------------------- |
1267e41f4b71Sopenharmony_ci| Promise<Array<[SimShortMessage](#simshortmessage7)\>&gt; | 以Promise形式返回获取的SIM短消息。 |
1268e41f4b71Sopenharmony_ci
1269e41f4b71Sopenharmony_ci**错误码:**
1270e41f4b71Sopenharmony_ci
1271e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1272e41f4b71Sopenharmony_ci
1273e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
1274e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1275e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
1276e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1277e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                           |
1278e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1279e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1280e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1281e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1282e41f4b71Sopenharmony_ci
1283e41f4b71Sopenharmony_ci**示例:**
1284e41f4b71Sopenharmony_ci
1285e41f4b71Sopenharmony_ci```ts
1286e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1287e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1288e41f4b71Sopenharmony_ci
1289e41f4b71Sopenharmony_cilet slotId: number = 0;
1290e41f4b71Sopenharmony_cilet promise = sms.getAllSimMessages(slotId);
1291e41f4b71Sopenharmony_cipromise.then((data: sms.SimShortMessage[]) => {
1292e41f4b71Sopenharmony_ci    console.log(`getAllSimMessages success, promise: data->${JSON.stringify(data)}`);
1293e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1294e41f4b71Sopenharmony_ci    console.error(`getAllSimMessages failed, promise: err->${JSON.stringify(err)}`);
1295e41f4b71Sopenharmony_ci});
1296e41f4b71Sopenharmony_ci```
1297e41f4b71Sopenharmony_ci
1298e41f4b71Sopenharmony_ci## sms.setCBConfig<sup>7+</sup>
1299e41f4b71Sopenharmony_ci
1300e41f4b71Sopenharmony_cisetCBConfig\(options: CBConfigOptions, callback: AsyncCallback\<void\>\): void
1301e41f4b71Sopenharmony_ci
1302e41f4b71Sopenharmony_ci设置小区广播配置。使用callback异步回调。
1303e41f4b71Sopenharmony_ci
1304e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1305e41f4b71Sopenharmony_ci
1306e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_SMS
1307e41f4b71Sopenharmony_ci
1308e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1309e41f4b71Sopenharmony_ci
1310e41f4b71Sopenharmony_ci**参数:**
1311e41f4b71Sopenharmony_ci
1312e41f4b71Sopenharmony_ci| 参数名   | 类型                                 | 必填 | 说明         |
1313e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------ |
1314e41f4b71Sopenharmony_ci| options  | [CBConfigOptions](#cbconfigoptions7) | 是   | 小区广播配置选项。 |
1315e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;            | 是   | 设置小区广播配置的回调函数。  |
1316e41f4b71Sopenharmony_ci
1317e41f4b71Sopenharmony_ci**错误码:**
1318e41f4b71Sopenharmony_ci
1319e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1320e41f4b71Sopenharmony_ci
1321e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
1322e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1323e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
1324e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1325e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                         |
1326e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1327e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1328e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1329e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1330e41f4b71Sopenharmony_ci
1331e41f4b71Sopenharmony_ci**示例:**
1332e41f4b71Sopenharmony_ci
1333e41f4b71Sopenharmony_ci```ts
1334e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1335e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1336e41f4b71Sopenharmony_ci
1337e41f4b71Sopenharmony_cilet cbConfigOptions: sms.CBConfigOptions = {
1338e41f4b71Sopenharmony_ci    slotId: 0,
1339e41f4b71Sopenharmony_ci    enable: true,
1340e41f4b71Sopenharmony_ci    startMessageId: 100,
1341e41f4b71Sopenharmony_ci    endMessageId: 200,
1342e41f4b71Sopenharmony_ci    ranType: sms.RanType.TYPE_GSM
1343e41f4b71Sopenharmony_ci};
1344e41f4b71Sopenharmony_cisms.setCBConfig(cbConfigOptions, (err: BusinessError) => {
1345e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}`);
1346e41f4b71Sopenharmony_ci});
1347e41f4b71Sopenharmony_ci```
1348e41f4b71Sopenharmony_ci
1349e41f4b71Sopenharmony_ci
1350e41f4b71Sopenharmony_ci## sms.setCBConfig<sup>7+</sup>
1351e41f4b71Sopenharmony_ci
1352e41f4b71Sopenharmony_cisetCBConfig\(options: CBConfigOptions\): Promise\<void\>
1353e41f4b71Sopenharmony_ci
1354e41f4b71Sopenharmony_ci设置小区广播配置。使用Promise异步回调。
1355e41f4b71Sopenharmony_ci
1356e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1357e41f4b71Sopenharmony_ci
1358e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.RECEIVE_SMS
1359e41f4b71Sopenharmony_ci
1360e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1361e41f4b71Sopenharmony_ci
1362e41f4b71Sopenharmony_ci**参数:**
1363e41f4b71Sopenharmony_ci
1364e41f4b71Sopenharmony_ci| 参数名  | 类型                                 | 必填 | 说明         |
1365e41f4b71Sopenharmony_ci| ------- | ------------------------------------ | ---- | ------------ |
1366e41f4b71Sopenharmony_ci| options | [CBConfigOptions](#cbconfigoptions7) | 是   | 小区广播配置选项。 |
1367e41f4b71Sopenharmony_ci
1368e41f4b71Sopenharmony_ci**返回值:**
1369e41f4b71Sopenharmony_ci
1370e41f4b71Sopenharmony_ci| 类型                | 说明                          |
1371e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
1372e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 以Promise形式返回设置的结果。 |
1373e41f4b71Sopenharmony_ci
1374e41f4b71Sopenharmony_ci**错误码:**
1375e41f4b71Sopenharmony_ci
1376e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1377e41f4b71Sopenharmony_ci
1378e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
1379e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1380e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
1381e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1382e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                         |
1383e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1384e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1385e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1386e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1387e41f4b71Sopenharmony_ci
1388e41f4b71Sopenharmony_ci**示例:**
1389e41f4b71Sopenharmony_ci
1390e41f4b71Sopenharmony_ci```ts
1391e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1392e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1393e41f4b71Sopenharmony_ci
1394e41f4b71Sopenharmony_cilet cbConfigOptions: sms.CBConfigOptions = {
1395e41f4b71Sopenharmony_ci    slotId: 0,
1396e41f4b71Sopenharmony_ci    enable: true,
1397e41f4b71Sopenharmony_ci    startMessageId: 100,
1398e41f4b71Sopenharmony_ci    endMessageId: 200,
1399e41f4b71Sopenharmony_ci    ranType: sms.RanType.TYPE_GSM
1400e41f4b71Sopenharmony_ci};
1401e41f4b71Sopenharmony_cilet promise = sms.setCBConfig(cbConfigOptions);
1402e41f4b71Sopenharmony_cipromise.then(() => {
1403e41f4b71Sopenharmony_ci    console.log(`setCBConfig success.`);
1404e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1405e41f4b71Sopenharmony_ci    console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`);
1406e41f4b71Sopenharmony_ci});
1407e41f4b71Sopenharmony_ci```
1408e41f4b71Sopenharmony_ci
1409e41f4b71Sopenharmony_ci## sms.getSmsSegmentsInfo<sup>8+</sup>
1410e41f4b71Sopenharmony_ci
1411e41f4b71Sopenharmony_cigetSmsSegmentsInfo\(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback\<SmsSegmentsInfo\>\): void
1412e41f4b71Sopenharmony_ci
1413e41f4b71Sopenharmony_ci获取短信段信息。使用callback异步回调。
1414e41f4b71Sopenharmony_ci
1415e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1416e41f4b71Sopenharmony_ci
1417e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1418e41f4b71Sopenharmony_ci
1419e41f4b71Sopenharmony_ci**参数:**
1420e41f4b71Sopenharmony_ci
1421e41f4b71Sopenharmony_ci| 参数名    | 类型                                                         | 必填 | 说明                                      |
1422e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------------ | ---- | ----------------------------------------- |
1423e41f4b71Sopenharmony_ci| slotId    | number                                                       | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1424e41f4b71Sopenharmony_ci| message   | string                                                       | 是   | 消息。                                      |
1425e41f4b71Sopenharmony_ci| force7bit | boolean                                                      | 是   | 是否使用7 bit编码。                          |
1426e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;[SmsSegmentsInfo](#smssegmentsinfo8)&gt; | 是   | 指示用于获取短信短信息的回调函数。  |
1427e41f4b71Sopenharmony_ci
1428e41f4b71Sopenharmony_ci**错误码:**
1429e41f4b71Sopenharmony_ci
1430e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1431e41f4b71Sopenharmony_ci
1432e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1433e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1434e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1435e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                            |
1436e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1437e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1438e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1439e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1440e41f4b71Sopenharmony_ci
1441e41f4b71Sopenharmony_ci**示例:**
1442e41f4b71Sopenharmony_ci
1443e41f4b71Sopenharmony_ci```ts
1444e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1445e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1446e41f4b71Sopenharmony_ci
1447e41f4b71Sopenharmony_cilet slotId: number = 0;
1448e41f4b71Sopenharmony_cisms.getSmsSegmentsInfo(slotId, "message", false, (err: BusinessError, data: sms.SmsSegmentsInfo) => {
1449e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1450e41f4b71Sopenharmony_ci});
1451e41f4b71Sopenharmony_ci```
1452e41f4b71Sopenharmony_ci
1453e41f4b71Sopenharmony_ci
1454e41f4b71Sopenharmony_ci## sms.getSmsSegmentsInfo<sup>8+</sup>
1455e41f4b71Sopenharmony_ci
1456e41f4b71Sopenharmony_cigetSmsSegmentsInfo\(slotId: number, message: string, force7bit: boolean\): Promise\<SmsSegmentsInfo\>
1457e41f4b71Sopenharmony_ci
1458e41f4b71Sopenharmony_ci获取短信段信息。使用Promise异步回调。
1459e41f4b71Sopenharmony_ci
1460e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1461e41f4b71Sopenharmony_ci
1462e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1463e41f4b71Sopenharmony_ci
1464e41f4b71Sopenharmony_ci**参数:**
1465e41f4b71Sopenharmony_ci
1466e41f4b71Sopenharmony_ci| 参数名    | 类型    | 必填 | 说明                                      |
1467e41f4b71Sopenharmony_ci| --------- | ------- | ---- | ----------------------------------------- |
1468e41f4b71Sopenharmony_ci| slotId    | number  | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1469e41f4b71Sopenharmony_ci| message   | string  | 是   | 消息。                                      |
1470e41f4b71Sopenharmony_ci| force7bit | boolean | 是   | 是否使用7 bit编码。                          |
1471e41f4b71Sopenharmony_ci
1472e41f4b71Sopenharmony_ci**返回值:**
1473e41f4b71Sopenharmony_ci
1474e41f4b71Sopenharmony_ci| 类型                                                    | 说明                          |
1475e41f4b71Sopenharmony_ci| ------------------------------------------------------- | ----------------------------- |
1476e41f4b71Sopenharmony_ci| Promise&lt;[SmsSegmentsInfo](#smssegmentsinfo8)&gt; | 以Promise形式返回短信段信息。 |
1477e41f4b71Sopenharmony_ci
1478e41f4b71Sopenharmony_ci**错误码:**
1479e41f4b71Sopenharmony_ci
1480e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1481e41f4b71Sopenharmony_ci
1482e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1483e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1484e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1485e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                            |
1486e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1487e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1488e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1489e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1490e41f4b71Sopenharmony_ci
1491e41f4b71Sopenharmony_ci**示例:**
1492e41f4b71Sopenharmony_ci
1493e41f4b71Sopenharmony_ci```ts
1494e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1495e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1496e41f4b71Sopenharmony_ci
1497e41f4b71Sopenharmony_cilet slotId: number = 0;
1498e41f4b71Sopenharmony_cilet promise = sms.getSmsSegmentsInfo(slotId, "message", false);
1499e41f4b71Sopenharmony_cipromise.then((data: sms.SmsSegmentsInfo) => {
1500e41f4b71Sopenharmony_ci    console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`);
1501e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1502e41f4b71Sopenharmony_ci    console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`);
1503e41f4b71Sopenharmony_ci});
1504e41f4b71Sopenharmony_ci```
1505e41f4b71Sopenharmony_ci
1506e41f4b71Sopenharmony_ci## sms.isImsSmsSupported<sup>8+</sup>
1507e41f4b71Sopenharmony_ci
1508e41f4b71Sopenharmony_ciisImsSmsSupported\(slotId: number, callback: AsyncCallback\<boolean\>\): void
1509e41f4b71Sopenharmony_ci
1510e41f4b71Sopenharmony_ci如果IMS已注册并且在IMS上支持SMS,则支持通过IMS发送SMS。使用callback异步回调。
1511e41f4b71Sopenharmony_ci
1512e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1513e41f4b71Sopenharmony_ci
1514e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1515e41f4b71Sopenharmony_ci
1516e41f4b71Sopenharmony_ci**参数:**
1517e41f4b71Sopenharmony_ci
1518e41f4b71Sopenharmony_ci| 参数名   | 类型                         | 必填 | 说明       |
1519e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | ---------- |
1520e41f4b71Sopenharmony_ci| slotId   | number                       | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1521e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;boolean&gt; | 是   | 指示是否支持IMS发送SMS的回调函数。 |
1522e41f4b71Sopenharmony_ci
1523e41f4b71Sopenharmony_ci**错误码:**
1524e41f4b71Sopenharmony_ci
1525e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1526e41f4b71Sopenharmony_ci
1527e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1528e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1529e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1530e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                          |
1531e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1532e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1533e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1534e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1535e41f4b71Sopenharmony_ci
1536e41f4b71Sopenharmony_ci**示例:**
1537e41f4b71Sopenharmony_ci
1538e41f4b71Sopenharmony_ci```ts
1539e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1540e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1541e41f4b71Sopenharmony_ci
1542e41f4b71Sopenharmony_cilet slotId: number = 0;
1543e41f4b71Sopenharmony_cisms.isImsSmsSupported(slotId, (err: BusinessError, data: boolean) => {
1544e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1545e41f4b71Sopenharmony_ci});
1546e41f4b71Sopenharmony_ci```
1547e41f4b71Sopenharmony_ci
1548e41f4b71Sopenharmony_ci
1549e41f4b71Sopenharmony_ci## sms.isImsSmsSupported<sup>8+</sup>
1550e41f4b71Sopenharmony_ci
1551e41f4b71Sopenharmony_ciisImsSmsSupported\(slotId: number\): Promise\<boolean\>
1552e41f4b71Sopenharmony_ci
1553e41f4b71Sopenharmony_ci如果IMS已注册并且在IMS上支持SMS,则支持通过IMS发送SMS。使用Promise异步回调。
1554e41f4b71Sopenharmony_ci
1555e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1556e41f4b71Sopenharmony_ci
1557e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1558e41f4b71Sopenharmony_ci
1559e41f4b71Sopenharmony_ci**参数:**
1560e41f4b71Sopenharmony_ci
1561e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填  | 说明                                  |
1562e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
1563e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1564e41f4b71Sopenharmony_ci
1565e41f4b71Sopenharmony_ci**返回值:**
1566e41f4b71Sopenharmony_ci
1567e41f4b71Sopenharmony_ci| 类型                   | 说明                    |
1568e41f4b71Sopenharmony_ci| ---------------------- | ----------------------- |
1569e41f4b71Sopenharmony_ci| Promise&lt;boolean&gt; | 以Promise形式返回结果。 |
1570e41f4b71Sopenharmony_ci
1571e41f4b71Sopenharmony_ci**错误码:**
1572e41f4b71Sopenharmony_ci
1573e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1574e41f4b71Sopenharmony_ci
1575e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1576e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1577e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1578e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                         |
1579e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1580e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1581e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1582e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1583e41f4b71Sopenharmony_ci
1584e41f4b71Sopenharmony_ci**示例:**
1585e41f4b71Sopenharmony_ci
1586e41f4b71Sopenharmony_ci```ts
1587e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1588e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1589e41f4b71Sopenharmony_ci
1590e41f4b71Sopenharmony_cilet slotId: number = 0;
1591e41f4b71Sopenharmony_cilet promise = sms.isImsSmsSupported(slotId);
1592e41f4b71Sopenharmony_cipromise.then((data: boolean) => {
1593e41f4b71Sopenharmony_ci    console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`);
1594e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1595e41f4b71Sopenharmony_ci    console.error(`isImsSmsSupported failed, promise: err->${JSON.stringify(err)}`);
1596e41f4b71Sopenharmony_ci});
1597e41f4b71Sopenharmony_ci```
1598e41f4b71Sopenharmony_ci
1599e41f4b71Sopenharmony_ci## sms.getImsShortMessageFormat<sup>8+</sup>
1600e41f4b71Sopenharmony_ci
1601e41f4b71Sopenharmony_cigetImsShortMessageFormat\(callback: AsyncCallback\<string\>\): void
1602e41f4b71Sopenharmony_ci
1603e41f4b71Sopenharmony_ci获取IMS上支持的SMS格式。使用callback异步回调。
1604e41f4b71Sopenharmony_ci
1605e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1606e41f4b71Sopenharmony_ci
1607e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1608e41f4b71Sopenharmony_ci
1609e41f4b71Sopenharmony_ci**参数:**
1610e41f4b71Sopenharmony_ci
1611e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明       |
1612e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------- |
1613e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;string&gt; | 是   | 指示用于获取格式、3gpp、3gpp2或未知的回调函数。 |
1614e41f4b71Sopenharmony_ci
1615e41f4b71Sopenharmony_ci**错误码:**
1616e41f4b71Sopenharmony_ci
1617e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1618e41f4b71Sopenharmony_ci
1619e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
1620e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1621e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1622e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                           |
1623e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1624e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1625e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1626e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1627e41f4b71Sopenharmony_ci
1628e41f4b71Sopenharmony_ci**示例:**
1629e41f4b71Sopenharmony_ci
1630e41f4b71Sopenharmony_ci```ts
1631e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1632e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1633e41f4b71Sopenharmony_ci
1634e41f4b71Sopenharmony_cisms.getImsShortMessageFormat((err: BusinessError, data: string) => {
1635e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1636e41f4b71Sopenharmony_ci});
1637e41f4b71Sopenharmony_ci```
1638e41f4b71Sopenharmony_ci
1639e41f4b71Sopenharmony_ci
1640e41f4b71Sopenharmony_ci## sms.getImsShortMessageFormat<sup>8+</sup>
1641e41f4b71Sopenharmony_ci
1642e41f4b71Sopenharmony_cigetImsShortMessageFormat\(\): Promise\<string\>
1643e41f4b71Sopenharmony_ci
1644e41f4b71Sopenharmony_ci获取IMS上支持的SMS格式。使用Promise异步回调。
1645e41f4b71Sopenharmony_ci
1646e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1647e41f4b71Sopenharmony_ci
1648e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1649e41f4b71Sopenharmony_ci
1650e41f4b71Sopenharmony_ci**返回值:**
1651e41f4b71Sopenharmony_ci
1652e41f4b71Sopenharmony_ci| 类型                  | 说明                       |
1653e41f4b71Sopenharmony_ci| --------------------- | -------------------------- |
1654e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | 以Promise形式返回SMS格式。 |
1655e41f4b71Sopenharmony_ci
1656e41f4b71Sopenharmony_ci**错误码:**
1657e41f4b71Sopenharmony_ci
1658e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1659e41f4b71Sopenharmony_ci
1660e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
1661e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1662e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1663e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1664e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1665e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1666e41f4b71Sopenharmony_ci
1667e41f4b71Sopenharmony_ci**示例:**
1668e41f4b71Sopenharmony_ci
1669e41f4b71Sopenharmony_ci```ts
1670e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1671e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1672e41f4b71Sopenharmony_ci
1673e41f4b71Sopenharmony_cisms.getImsShortMessageFormat().then((data: string) => {
1674e41f4b71Sopenharmony_ci    console.log(`getImsShortMessageFormat success, promise: data->${JSON.stringify(data)}`);
1675e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1676e41f4b71Sopenharmony_ci    console.error(`getImsShortMessageFormat failed, promise: err->${JSON.stringify(err)}`);
1677e41f4b71Sopenharmony_ci});
1678e41f4b71Sopenharmony_ci```
1679e41f4b71Sopenharmony_ci
1680e41f4b71Sopenharmony_ci## sms.decodeMms<sup>8+</sup>
1681e41f4b71Sopenharmony_ci
1682e41f4b71Sopenharmony_cidecodeMms\(mmsFilePathName: string | Array\<number\>, callback: AsyncCallback\<MmsInformation\>\): void
1683e41f4b71Sopenharmony_ci
1684e41f4b71Sopenharmony_ci彩信解码。使用callback异步回调。
1685e41f4b71Sopenharmony_ci
1686e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1687e41f4b71Sopenharmony_ci
1688e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1689e41f4b71Sopenharmony_ci
1690e41f4b71Sopenharmony_ci**参数:**
1691e41f4b71Sopenharmony_ci
1692e41f4b71Sopenharmony_ci| 参数名          | 类型                                                    | 必填 | 说明           |
1693e41f4b71Sopenharmony_ci| --------------- | ------------------------------------------------------- | ---- | -------------- |
1694e41f4b71Sopenharmony_ci| mmsFilePathName | string \|Array<number\>                                 | 是   | 彩信文件路径。 |
1695e41f4b71Sopenharmony_ci| callback        | AsyncCallback&lt;[MmsInformation](#mmsinformation8)&gt; | 是   | 获取{@code MmsInformation}的回调函数。     |
1696e41f4b71Sopenharmony_ci
1697e41f4b71Sopenharmony_ci**错误码:**
1698e41f4b71Sopenharmony_ci
1699e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1700e41f4b71Sopenharmony_ci
1701e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1702e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1703e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1704e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                            |
1705e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1706e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1707e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1708e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1709e41f4b71Sopenharmony_ci
1710e41f4b71Sopenharmony_ci**示例:**
1711e41f4b71Sopenharmony_ci
1712e41f4b71Sopenharmony_ci```ts
1713e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1714e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1715e41f4b71Sopenharmony_ci
1716e41f4b71Sopenharmony_cilet mmsFilePathName: string = "filename";
1717e41f4b71Sopenharmony_cisms.decodeMms(mmsFilePathName, (err: BusinessError, data: sms.MmsInformation) => {
1718e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1719e41f4b71Sopenharmony_ci});
1720e41f4b71Sopenharmony_ci
1721e41f4b71Sopenharmony_ciconst 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];
1722e41f4b71Sopenharmony_cisms.decodeMms(mmsPdu, (err: BusinessError, data: sms.MmsInformation) => {
1723e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1724e41f4b71Sopenharmony_ci});
1725e41f4b71Sopenharmony_ci```
1726e41f4b71Sopenharmony_ci
1727e41f4b71Sopenharmony_ci
1728e41f4b71Sopenharmony_ci## sms.decodeMms<sup>8+</sup>
1729e41f4b71Sopenharmony_ci
1730e41f4b71Sopenharmony_cidecodeMms\(mmsFilePathName: string | Array\<number\>\): Promise\<MmsInformation\>
1731e41f4b71Sopenharmony_ci
1732e41f4b71Sopenharmony_ci彩信解码。使用Promise异步回调。
1733e41f4b71Sopenharmony_ci
1734e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1735e41f4b71Sopenharmony_ci
1736e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1737e41f4b71Sopenharmony_ci
1738e41f4b71Sopenharmony_ci**参数:**
1739e41f4b71Sopenharmony_ci
1740e41f4b71Sopenharmony_ci| 参数名          | 类型                    | 必填 | 说明           |
1741e41f4b71Sopenharmony_ci| --------------- | ----------------------- | ---- | -------------- |
1742e41f4b71Sopenharmony_ci| mmsFilePathName | string \|Array<number\> | 是   | 彩信文件路径。 |
1743e41f4b71Sopenharmony_ci
1744e41f4b71Sopenharmony_ci**返回值:**
1745e41f4b71Sopenharmony_ci
1746e41f4b71Sopenharmony_ci| 类型                                                      | 说明                        |
1747e41f4b71Sopenharmony_ci| --------------------------------------------------------- | --------------------------- |
1748e41f4b71Sopenharmony_ci| Promise&lt;&lt;[MmsInformation](#mmsinformation8)&gt;&gt; | 以Promise形式返回彩信信息。 |
1749e41f4b71Sopenharmony_ci
1750e41f4b71Sopenharmony_ci**错误码:**
1751e41f4b71Sopenharmony_ci
1752e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1753e41f4b71Sopenharmony_ci
1754e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1755e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1756e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1757e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                            |
1758e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1759e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1760e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1761e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1762e41f4b71Sopenharmony_ci
1763e41f4b71Sopenharmony_ci**示例:**
1764e41f4b71Sopenharmony_ci
1765e41f4b71Sopenharmony_ci```ts
1766e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1767e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1768e41f4b71Sopenharmony_ci
1769e41f4b71Sopenharmony_cilet mmsFilePathName: string = "filename";
1770e41f4b71Sopenharmony_cilet promise = sms.decodeMms(mmsFilePathName);
1771e41f4b71Sopenharmony_cipromise.then((data: sms.MmsInformation) => {
1772e41f4b71Sopenharmony_ci    console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`);
1773e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1774e41f4b71Sopenharmony_ci    console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`);
1775e41f4b71Sopenharmony_ci});
1776e41f4b71Sopenharmony_ci
1777e41f4b71Sopenharmony_ciconst 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];
1778e41f4b71Sopenharmony_cilet promiseArr = sms.decodeMms(mmsPdu);
1779e41f4b71Sopenharmony_cipromiseArr.then((data: sms.MmsInformation) => {
1780e41f4b71Sopenharmony_ci    console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`);
1781e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1782e41f4b71Sopenharmony_ci    console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`);
1783e41f4b71Sopenharmony_ci});
1784e41f4b71Sopenharmony_ci```
1785e41f4b71Sopenharmony_ci
1786e41f4b71Sopenharmony_ci## sms.encodeMms<sup>8+</sup>
1787e41f4b71Sopenharmony_ci
1788e41f4b71Sopenharmony_ciencodeMms\(mms: MmsInformation, callback: AsyncCallback\<Array\<number\>\>\): void
1789e41f4b71Sopenharmony_ci
1790e41f4b71Sopenharmony_ci彩信编码。使用callback异步回调。
1791e41f4b71Sopenharmony_ci
1792e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1793e41f4b71Sopenharmony_ci
1794e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1795e41f4b71Sopenharmony_ci
1796e41f4b71Sopenharmony_ci**参数:**
1797e41f4b71Sopenharmony_ci
1798e41f4b71Sopenharmony_ci| 参数名   | 类型                                | 必填 | 说明       |
1799e41f4b71Sopenharmony_ci| -------- | ----------------------------------- | ---- | ---------- |
1800e41f4b71Sopenharmony_ci| mms      | [MmsInformation](#mmsinformation8)  | 是   | 彩信信息。 |
1801e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;Array<number\>&gt; | 是   | 指示用于获取MMS编码结果的回调函数。 |
1802e41f4b71Sopenharmony_ci
1803e41f4b71Sopenharmony_ci**错误码:**
1804e41f4b71Sopenharmony_ci
1805e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1806e41f4b71Sopenharmony_ci
1807e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1808e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1809e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1810e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                            |
1811e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1812e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1813e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1814e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1815e41f4b71Sopenharmony_ci
1816e41f4b71Sopenharmony_ci**示例:**
1817e41f4b71Sopenharmony_ci
1818e41f4b71Sopenharmony_ci```ts
1819e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1820e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1821e41f4b71Sopenharmony_ci
1822e41f4b71Sopenharmony_cilet mmsAcknowledgeInd: sms.MmsAcknowledgeInd = {
1823e41f4b71Sopenharmony_ci    transactionId: "100",
1824e41f4b71Sopenharmony_ci    version: sms.MmsVersionType.MMS_VERSION_1_0,
1825e41f4b71Sopenharmony_ci    reportAllowed: sms.ReportType.MMS_YES
1826e41f4b71Sopenharmony_ci};
1827e41f4b71Sopenharmony_cilet mmsInformation: sms.MmsInformation = {
1828e41f4b71Sopenharmony_ci    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
1829e41f4b71Sopenharmony_ci    mmsType: mmsAcknowledgeInd
1830e41f4b71Sopenharmony_ci};
1831e41f4b71Sopenharmony_cisms.encodeMms(mmsInformation, (err: BusinessError, data: number[]) => {
1832e41f4b71Sopenharmony_ci      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1833e41f4b71Sopenharmony_ci});
1834e41f4b71Sopenharmony_ci```
1835e41f4b71Sopenharmony_ci
1836e41f4b71Sopenharmony_ci
1837e41f4b71Sopenharmony_ci## sms.encodeMms<sup>8+</sup>
1838e41f4b71Sopenharmony_ci
1839e41f4b71Sopenharmony_ciencodeMms\(mms: MmsInformation\): Promise\<Array\<number\>\>
1840e41f4b71Sopenharmony_ci
1841e41f4b71Sopenharmony_ci彩信编码。使用Promise异步回调。
1842e41f4b71Sopenharmony_ci
1843e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1844e41f4b71Sopenharmony_ci
1845e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1846e41f4b71Sopenharmony_ci
1847e41f4b71Sopenharmony_ci**参数:**
1848e41f4b71Sopenharmony_ci
1849e41f4b71Sopenharmony_ci| 参数名 | 类型                               | 必填 | 说明       |
1850e41f4b71Sopenharmony_ci| ------ | ---------------------------------- | ---- | ---------- |
1851e41f4b71Sopenharmony_ci| mms    | [MmsInformation](#mmsinformation8) | 是   | 彩信信息。 |
1852e41f4b71Sopenharmony_ci
1853e41f4b71Sopenharmony_ci**返回值:**
1854e41f4b71Sopenharmony_ci
1855e41f4b71Sopenharmony_ci| 类型                          | 说明                                |
1856e41f4b71Sopenharmony_ci| ----------------------------- | ----------------------------------- |
1857e41f4b71Sopenharmony_ci| Promise&lt;Array<number\>&gt; | 以Promise形式返回彩信编码后的结果。 |
1858e41f4b71Sopenharmony_ci
1859e41f4b71Sopenharmony_ci**错误码:**
1860e41f4b71Sopenharmony_ci
1861e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1862e41f4b71Sopenharmony_ci
1863e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1864e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1865e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
1866e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                            |
1867e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1868e41f4b71Sopenharmony_ci| 8300002  | Operation failed. Cannot connect to service. |
1869e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1870e41f4b71Sopenharmony_ci| 8300999  | Unknown error code.                          |
1871e41f4b71Sopenharmony_ci
1872e41f4b71Sopenharmony_ci**示例:**
1873e41f4b71Sopenharmony_ci
1874e41f4b71Sopenharmony_ci```ts
1875e41f4b71Sopenharmony_ciimport { sms } from '@kit.TelephonyKit';
1876e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1877e41f4b71Sopenharmony_ci
1878e41f4b71Sopenharmony_cilet mmsAcknowledgeInd: sms.MmsAcknowledgeInd = {
1879e41f4b71Sopenharmony_ci    transactionId: "100",
1880e41f4b71Sopenharmony_ci    version: sms.MmsVersionType.MMS_VERSION_1_0,
1881e41f4b71Sopenharmony_ci    reportAllowed: sms.ReportType.MMS_YES
1882e41f4b71Sopenharmony_ci};
1883e41f4b71Sopenharmony_cilet mmsInformation: sms.MmsInformation = {
1884e41f4b71Sopenharmony_ci    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
1885e41f4b71Sopenharmony_ci    mmsType: mmsAcknowledgeInd
1886e41f4b71Sopenharmony_ci};
1887e41f4b71Sopenharmony_cisms.encodeMms(mmsInformation).then((data: number[]) => {
1888e41f4b71Sopenharmony_ci    console.log(`encodeMms success, promise: data->${JSON.stringify(data)}`);
1889e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1890e41f4b71Sopenharmony_ci    console.error(`encodeMms failed, promise: err->${JSON.stringify(err)}`);
1891e41f4b71Sopenharmony_ci});
1892e41f4b71Sopenharmony_ci```
1893e41f4b71Sopenharmony_ci
1894e41f4b71Sopenharmony_ci
1895e41f4b71Sopenharmony_ci## MmsParams<sup>11+</sup>
1896e41f4b71Sopenharmony_ci
1897e41f4b71Sopenharmony_ci发送彩信的参数。
1898e41f4b71Sopenharmony_ci
1899e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1900e41f4b71Sopenharmony_ci
1901e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1902e41f4b71Sopenharmony_ci
1903e41f4b71Sopenharmony_ci|       名称       | 类型                                                         | 必填 | 说明                                                         |
1904e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1905e41f4b71Sopenharmony_ci| slotId<sup>11+</sup>           | number                                                       | 是   | 用于发送短信的SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2      |
1906e41f4b71Sopenharmony_ci| mmsc<sup>11+</sup>  | string                                                       | 是   | 彩信中心地址。                                             |
1907e41f4b71Sopenharmony_ci| data<sup>11+</sup>          | string                               | 是   | 彩信PDU地址。 |
1908e41f4b71Sopenharmony_ci| mmsConfig<sup>11+</sup>    | MmsConfig                                                       | 否   | 彩信配置文件,参考[MmsConfig](#mmsconfig11)。                |
1909e41f4b71Sopenharmony_ci
1910e41f4b71Sopenharmony_ci## MmsConfig<sup>11+</sup>
1911e41f4b71Sopenharmony_ci
1912e41f4b71Sopenharmony_ci彩信配置文件。
1913e41f4b71Sopenharmony_ci
1914e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1915e41f4b71Sopenharmony_ci
1916e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1917e41f4b71Sopenharmony_ci
1918e41f4b71Sopenharmony_ci|       名称       | 类型                                                         | 必填 | 说明                                                         |
1919e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1920e41f4b71Sopenharmony_ci| userAgent<sup>11+</sup>  | string                                                       | 是   | 用户代理。                                             |
1921e41f4b71Sopenharmony_ci| userAgentProfile<sup>11+</sup>    | string                                                       | 是   | 用户代理配置。                |
1922e41f4b71Sopenharmony_ci
1923e41f4b71Sopenharmony_ci
1924e41f4b71Sopenharmony_ci
1925e41f4b71Sopenharmony_ci## MmsInformation<sup>8+</sup>
1926e41f4b71Sopenharmony_ci
1927e41f4b71Sopenharmony_ci彩信信息。
1928e41f4b71Sopenharmony_ci
1929e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1930e41f4b71Sopenharmony_ci
1931e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1932e41f4b71Sopenharmony_ci
1933e41f4b71Sopenharmony_ci|     名称    | 类型                                                         | 必填 |    说明    |
1934e41f4b71Sopenharmony_ci| ----------- | ------------------------------------------------------------ | ---- | ---------- |
1935e41f4b71Sopenharmony_ci| messageType | [MessageType](#messagetype8)                                 | 是   | 消息类型。 |
1936e41f4b71Sopenharmony_ci| mmsType     | [MmsSendReq](#mmssendreq8) \|[MmsSendConf](#mmssendconf8) \|[MmsNotificationInd](#mmsnotificationind8) \|[MmsRespInd](#mmsrespind8) \|[MmsRetrieveConf](#mmsretrieveconf8)\|[MmsAcknowledgeInd](#mmsacknowledgeind8)\|[MmsDeliveryInd](#mmsdeliveryind8)\|[MmsReadOrigInd](#mmsreadorigind8)\|[MmsReadRecInd](#mmsreadrecind8) | 是   | PDU头类型 |
1937e41f4b71Sopenharmony_ci| attachment  | Array<[MmsAttachment](#mmsattachment8)\>                     | 否   | 附件      |
1938e41f4b71Sopenharmony_ci
1939e41f4b71Sopenharmony_ci## MmsSendReq<sup>8+</sup>
1940e41f4b71Sopenharmony_ci
1941e41f4b71Sopenharmony_ci彩信发送请求。
1942e41f4b71Sopenharmony_ci
1943e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1944e41f4b71Sopenharmony_ci
1945e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1946e41f4b71Sopenharmony_ci
1947e41f4b71Sopenharmony_ci|       名称       | 类型                                 | 必填 | 说明         |
1948e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------ | ---- | ------------ |
1949e41f4b71Sopenharmony_ci| from             | [MmsAddress](#mmsaddress8)           | 是   | 彩信来源     |
1950e41f4b71Sopenharmony_ci| transactionId    | string                               | 是   | 事务ID       |
1951e41f4b71Sopenharmony_ci| contentType      | string                               | 是   | 内容类型     |
1952e41f4b71Sopenharmony_ci| version          | [MmsVersionType](#mmsversiontype8)   | 是   | 版本         |
1953e41f4b71Sopenharmony_ci| to               | Array<[MmsAddress](#mmsaddress8)\>   | 否   | 发送至       |
1954e41f4b71Sopenharmony_ci| date             | number                               | 否   | 日期         |
1955e41f4b71Sopenharmony_ci| cc               | Array<[MmsAddress](#mmsaddress8)\>   | 否   | 抄送         |
1956e41f4b71Sopenharmony_ci| bcc              | Array<[MmsAddress](#mmsaddress8)\>   | 否   | 暗抄送       |
1957e41f4b71Sopenharmony_ci| subject          | string                               | 否   | 主题         |
1958e41f4b71Sopenharmony_ci| messageClass     | number                               | 否   | 消息类       |
1959e41f4b71Sopenharmony_ci| expiry           | number                               | 否   | 到期         |
1960e41f4b71Sopenharmony_ci| priority         | [MmsPriorityType](#mmsprioritytype8) | 否   | 优先         |
1961e41f4b71Sopenharmony_ci| senderVisibility | number                               | 否   | 发件人可见性 |
1962e41f4b71Sopenharmony_ci| deliveryReport   | number                               | 否   | 交付报告     |
1963e41f4b71Sopenharmony_ci| readReport       | number                               | 否   | 阅读报告     |
1964e41f4b71Sopenharmony_ci
1965e41f4b71Sopenharmony_ci## MmsSendConf<sup>8+</sup>
1966e41f4b71Sopenharmony_ci
1967e41f4b71Sopenharmony_ci彩信发送配置。
1968e41f4b71Sopenharmony_ci
1969e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1970e41f4b71Sopenharmony_ci
1971e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1972e41f4b71Sopenharmony_ci
1973e41f4b71Sopenharmony_ci|     名称      | 类型                               | 必填 | 说明     |
1974e41f4b71Sopenharmony_ci| ------------- | ---------------------------------- | ---- | -------- |
1975e41f4b71Sopenharmony_ci| responseState | number                             | 是   | 响应状态 |
1976e41f4b71Sopenharmony_ci| transactionId | string                             | 是   | 事务ID   |
1977e41f4b71Sopenharmony_ci| version       | [MmsVersionType](#mmsversiontype8) | 是   | 版本     |
1978e41f4b71Sopenharmony_ci| messageId     | string                             | 否   | 消息ID   |
1979e41f4b71Sopenharmony_ci
1980e41f4b71Sopenharmony_ci## MmsNotificationInd<sup>8+</sup>
1981e41f4b71Sopenharmony_ci
1982e41f4b71Sopenharmony_ci彩信通知索引。
1983e41f4b71Sopenharmony_ci
1984e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1985e41f4b71Sopenharmony_ci
1986e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
1987e41f4b71Sopenharmony_ci
1988e41f4b71Sopenharmony_ci|      名称       | 类型                               | 必填 | 说明     |
1989e41f4b71Sopenharmony_ci| --------------- | ---------------------------------- | ---- | -------- |
1990e41f4b71Sopenharmony_ci| transactionId   | string                             | 是   | 事务ID   |
1991e41f4b71Sopenharmony_ci| messageClass    | number                             | 是   | 消息类   |
1992e41f4b71Sopenharmony_ci| messageSize     | number                             | 是   | 消息大小 |
1993e41f4b71Sopenharmony_ci| expiry          | number                             | 是   | 到期     |
1994e41f4b71Sopenharmony_ci| contentLocation | string                             | 是   | 内容位置 |
1995e41f4b71Sopenharmony_ci| version         | [MmsVersionType](#mmsversiontype8) | 是   | 版本     |
1996e41f4b71Sopenharmony_ci| from            | [MmsAddress](#mmsaddress8)         | 否   | 来源     |
1997e41f4b71Sopenharmony_ci| subject         | string                             | 否   | 主题     |
1998e41f4b71Sopenharmony_ci| deliveryReport  | number                             | 否   | 状态报告 |
1999e41f4b71Sopenharmony_ci| contentClass    | number                             | 否   | 内容类   |
2000e41f4b71Sopenharmony_ci
2001e41f4b71Sopenharmony_ci## MmsAcknowledgeInd<sup>8+</sup>
2002e41f4b71Sopenharmony_ci
2003e41f4b71Sopenharmony_ci彩信确认索引。
2004e41f4b71Sopenharmony_ci
2005e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2006e41f4b71Sopenharmony_ci
2007e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2008e41f4b71Sopenharmony_ci
2009e41f4b71Sopenharmony_ci|      名称     | 类型                               | 必填 | 说明     |
2010e41f4b71Sopenharmony_ci| ------------- | ---------------------------------- | ---- | -------- |
2011e41f4b71Sopenharmony_ci| transactionId | string                             | 是   | 事务ID   |
2012e41f4b71Sopenharmony_ci| version       | [MmsVersionType](#mmsversiontype8) | 是   | 版本     |
2013e41f4b71Sopenharmony_ci| reportAllowed | [ReportType](#reporttype8)         | 否   | 允许报告 |
2014e41f4b71Sopenharmony_ci
2015e41f4b71Sopenharmony_ci## MmsRetrieveConf<sup>8+</sup>
2016e41f4b71Sopenharmony_ci
2017e41f4b71Sopenharmony_ci彩信检索配置。
2018e41f4b71Sopenharmony_ci
2019e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2020e41f4b71Sopenharmony_ci
2021e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2022e41f4b71Sopenharmony_ci
2023e41f4b71Sopenharmony_ci|      名称      | 类型                                 | 必填 | 说明     |
2024e41f4b71Sopenharmony_ci| -------------- | ------------------------------------ | ---- | -------- |
2025e41f4b71Sopenharmony_ci| transactionId  | string                               | 是   | 事务ID   |
2026e41f4b71Sopenharmony_ci| messageId      | string                               | 是   | 消息ID   |
2027e41f4b71Sopenharmony_ci| date           | number                               | 是   | 日期     |
2028e41f4b71Sopenharmony_ci| contentType    | string                               | 是   | 内容类型 |
2029e41f4b71Sopenharmony_ci| to             | Array<[MmsAddress](#mmsaddress8)\>   | 是   | 发送至   |
2030e41f4b71Sopenharmony_ci| version        | [MmsVersionType](#mmsversiontype8)   | 是   | 版本     |
2031e41f4b71Sopenharmony_ci| from           | [MmsAddress](#mmsaddress8)           | 否   | 来源     |
2032e41f4b71Sopenharmony_ci| cc             | Array<[MmsAddress](#mmsaddress8)\>   | 否   | 抄送     |
2033e41f4b71Sopenharmony_ci| subject        | string                               | 否   | 主题     |
2034e41f4b71Sopenharmony_ci| priority       | [MmsPriorityType](#mmsprioritytype8) | 否   | 优先级   |
2035e41f4b71Sopenharmony_ci| deliveryReport | number                               | 否   | 状态报告 |
2036e41f4b71Sopenharmony_ci| readReport     | number                               | 否   | 阅读报告 |
2037e41f4b71Sopenharmony_ci| retrieveStatus | number                               | 否   | 检索状态 |
2038e41f4b71Sopenharmony_ci| retrieveText   | string                               | 否   | 检索文本 |
2039e41f4b71Sopenharmony_ci
2040e41f4b71Sopenharmony_ci## MmsReadOrigInd<sup>8+</sup>
2041e41f4b71Sopenharmony_ci
2042e41f4b71Sopenharmony_ci彩信读取原始索引。
2043e41f4b71Sopenharmony_ci
2044e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2045e41f4b71Sopenharmony_ci
2046e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2047e41f4b71Sopenharmony_ci
2048e41f4b71Sopenharmony_ci|    名称    | 类型                               | 必填 | 说明     |
2049e41f4b71Sopenharmony_ci| ---------- | ---------------------------------- | ---- | -------- |
2050e41f4b71Sopenharmony_ci| version    | [MmsVersionType](#mmsversiontype8) | 是   | 版本     |
2051e41f4b71Sopenharmony_ci| messageId  | string                             | 是   | 消息ID   |
2052e41f4b71Sopenharmony_ci| to         | Array<[MmsAddress](#mmsaddress8)\> | 是   | 发送至   |
2053e41f4b71Sopenharmony_ci| from       | [MmsAddress](#mmsaddress8)         | 是   | 来源     |
2054e41f4b71Sopenharmony_ci| date       | number                             | 是   | 日期     |
2055e41f4b71Sopenharmony_ci| readStatus | number                             | 是   | 阅读状态 |
2056e41f4b71Sopenharmony_ci
2057e41f4b71Sopenharmony_ci## MmsReadRecInd<sup>8+</sup>
2058e41f4b71Sopenharmony_ci
2059e41f4b71Sopenharmony_ci彩信读取记录索引。
2060e41f4b71Sopenharmony_ci
2061e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2062e41f4b71Sopenharmony_ci
2063e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2064e41f4b71Sopenharmony_ci
2065e41f4b71Sopenharmony_ci|    名称    | 类型                               | 必填 | 说明     |
2066e41f4b71Sopenharmony_ci| ---------- | ---------------------------------- | ---- | -------- |
2067e41f4b71Sopenharmony_ci| version    | [MmsVersionType](#mmsversiontype8) | 是   | 版本     |
2068e41f4b71Sopenharmony_ci| messageId  | string                             | 是   | 消息ID   |
2069e41f4b71Sopenharmony_ci| to         | Array<[MmsAddress](#mmsaddress8)\> | 是   | 发送至   |
2070e41f4b71Sopenharmony_ci| from       | [MmsAddress](#mmsaddress8)         | 是   | 来源     |
2071e41f4b71Sopenharmony_ci| readStatus | number                             | 是   | 阅读状态 |
2072e41f4b71Sopenharmony_ci| date       | number                             | 否   | 日期     |
2073e41f4b71Sopenharmony_ci
2074e41f4b71Sopenharmony_ci## MmsAttachment<sup>8+</sup>
2075e41f4b71Sopenharmony_ci
2076e41f4b71Sopenharmony_ci彩信附件。
2077e41f4b71Sopenharmony_ci
2078e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2079e41f4b71Sopenharmony_ci
2080e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2081e41f4b71Sopenharmony_ci
2082e41f4b71Sopenharmony_ci|          名称           | 类型                                 | 必填 | 说明               |
2083e41f4b71Sopenharmony_ci| ----------------------- | ------------------------------------ | ---- | ------------------ |
2084e41f4b71Sopenharmony_ci| contentId               | string                               | 是   | 内容ID             |
2085e41f4b71Sopenharmony_ci| contentLocation         | string                               | 是   | 内容位置           |
2086e41f4b71Sopenharmony_ci| contentDisposition      | [DispositionType](#dispositiontype8) | 是   | 内容处理           |
2087e41f4b71Sopenharmony_ci| contentTransferEncoding | string                               | 是   | 内容传输编码       |
2088e41f4b71Sopenharmony_ci| contentType             | string                               | 是   | 内容类型           |
2089e41f4b71Sopenharmony_ci| isSmil                  | boolean                              | 是   | 同步多媒体集成语言 |
2090e41f4b71Sopenharmony_ci| path                    | string                               | 否   | 路径               |
2091e41f4b71Sopenharmony_ci| inBuff                  | Array<number\>                       | 否   | 缓冲区中           |
2092e41f4b71Sopenharmony_ci| fileName                | string                               | 否   | 文件名             |
2093e41f4b71Sopenharmony_ci| charset                 | [MmsCharSets](#mmscharsets8)         | 否   | 字符集             |
2094e41f4b71Sopenharmony_ci
2095e41f4b71Sopenharmony_ci## MmsAddress<sup>8+</sup>
2096e41f4b71Sopenharmony_ci
2097e41f4b71Sopenharmony_ci彩信地址。
2098e41f4b71Sopenharmony_ci
2099e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2100e41f4b71Sopenharmony_ci
2101e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2102e41f4b71Sopenharmony_ci
2103e41f4b71Sopenharmony_ci|   名称  | 类型                         | 必填 | 说明   |
2104e41f4b71Sopenharmony_ci| ------- | ---------------------------- | ---- | ------ |
2105e41f4b71Sopenharmony_ci| address | string                       | 是   | 地址   |
2106e41f4b71Sopenharmony_ci| charset | [MmsCharSets](#mmscharsets8) | 是   | 字符集 |
2107e41f4b71Sopenharmony_ci
2108e41f4b71Sopenharmony_ci## MessageType<sup>8+</sup>
2109e41f4b71Sopenharmony_ci
2110e41f4b71Sopenharmony_ci消息类型。
2111e41f4b71Sopenharmony_ci
2112e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2113e41f4b71Sopenharmony_ci
2114e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2115e41f4b71Sopenharmony_ci
2116e41f4b71Sopenharmony_ci|          名称             | 值   | 说明                 |
2117e41f4b71Sopenharmony_ci| ------------------------- | ---- | -------------------- |
2118e41f4b71Sopenharmony_ci| TYPE_MMS_SEND_REQ         | 128  | 彩信发送请求类型     |
2119e41f4b71Sopenharmony_ci| TYPE_MMS_SEND_CONF        | 129  | 彩信发送配置类型     |
2120e41f4b71Sopenharmony_ci| TYPE_MMS_NOTIFICATION_IND | 130  | 彩信通知索引类型     |
2121e41f4b71Sopenharmony_ci| TYPE_MMS_RESP_IND         | 131  | 彩信回复索引类型     |
2122e41f4b71Sopenharmony_ci| TYPE_MMS_RETRIEVE_CONF    | 132  | 彩信检索配置类型     |
2123e41f4b71Sopenharmony_ci| TYPE_MMS_ACKNOWLEDGE_IND  | 133  | 彩信确认索引类型     |
2124e41f4b71Sopenharmony_ci| TYPE_MMS_DELIVERY_IND     | 134  | 彩信传送索引类型     |
2125e41f4b71Sopenharmony_ci| TYPE_MMS_READ_REC_IND     | 135  | 彩信读取接收索引类型 |
2126e41f4b71Sopenharmony_ci| TYPE_MMS_READ_ORIG_IND    | 136  | 彩信读取原始索引类型 |
2127e41f4b71Sopenharmony_ci
2128e41f4b71Sopenharmony_ci## MmsPriorityType<sup>8+</sup>
2129e41f4b71Sopenharmony_ci
2130e41f4b71Sopenharmony_ci彩信优先级类型。
2131e41f4b71Sopenharmony_ci
2132e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2133e41f4b71Sopenharmony_ci
2134e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2135e41f4b71Sopenharmony_ci
2136e41f4b71Sopenharmony_ci|    名称    | 值   | 说明           |
2137e41f4b71Sopenharmony_ci| ---------- | ---- | -------------- |
2138e41f4b71Sopenharmony_ci| MMS_LOW    | 128  | 彩信优先级低   |
2139e41f4b71Sopenharmony_ci| MMS_NORMAL | 129  | 彩信优先级正常 |
2140e41f4b71Sopenharmony_ci| MMS_HIGH   | 130  | 彩信优先级高   |
2141e41f4b71Sopenharmony_ci
2142e41f4b71Sopenharmony_ci## MmsVersionType<sup>8+</sup>
2143e41f4b71Sopenharmony_ci
2144e41f4b71Sopenharmony_ci彩信版本类型。
2145e41f4b71Sopenharmony_ci
2146e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2147e41f4b71Sopenharmony_ci
2148e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2149e41f4b71Sopenharmony_ci
2150e41f4b71Sopenharmony_ci|      名称       | 值   | 说明        |
2151e41f4b71Sopenharmony_ci| --------------- | ---- | ----------- |
2152e41f4b71Sopenharmony_ci| MMS_VERSION_1_0 | 0x10 | 彩信版本1_0 |
2153e41f4b71Sopenharmony_ci| MMS_VERSION_1_1 | 0x11 | 彩信版本1_1 |
2154e41f4b71Sopenharmony_ci| MMS_VERSION_1_2 | 0x12 | 彩信版本1_2 |
2155e41f4b71Sopenharmony_ci| MMS_VERSION_1_3 | 0x13 | 彩信版本1_3 |
2156e41f4b71Sopenharmony_ci
2157e41f4b71Sopenharmony_ci## MmsCharSets<sup>8+</sup>
2158e41f4b71Sopenharmony_ci
2159e41f4b71Sopenharmony_ci彩信字符集。
2160e41f4b71Sopenharmony_ci
2161e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2162e41f4b71Sopenharmony_ci
2163e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2164e41f4b71Sopenharmony_ci
2165e41f4b71Sopenharmony_ci|      名称       | 值     | 说明                |
2166e41f4b71Sopenharmony_ci| --------------- | ------ | ------------------- |
2167e41f4b71Sopenharmony_ci| BIG5            | 0X07EA | BIG5格式            |
2168e41f4b71Sopenharmony_ci| ISO_10646_UCS_2 | 0X03E8 | ISO_10646_UCS_2格式 |
2169e41f4b71Sopenharmony_ci| ISO_8859_1      | 0X04   | ISO_8859_1格式      |
2170e41f4b71Sopenharmony_ci| ISO_8859_2      | 0X05   | ISO_8859_2格式      |
2171e41f4b71Sopenharmony_ci| ISO_8859_3      | 0X06   | ISO_8859_3格式      |
2172e41f4b71Sopenharmony_ci| ISO_8859_4      | 0X07   | ISO_8859_4格式      |
2173e41f4b71Sopenharmony_ci| ISO_8859_5      | 0X08   | ISO_8859_5格式      |
2174e41f4b71Sopenharmony_ci| ISO_8859_6      | 0X09   | ISO_8859_6格式      |
2175e41f4b71Sopenharmony_ci| ISO_8859_7      | 0X0A   | ISO_8859_7格式      |
2176e41f4b71Sopenharmony_ci| ISO_8859_8      | 0X0B   | ISO_8859_8格式      |
2177e41f4b71Sopenharmony_ci| ISO_8859_9      | 0X0C   | ISO_8859_9格式      |
2178e41f4b71Sopenharmony_ci| SHIFT_JIS       | 0X11   | SHIFT_JIS格式       |
2179e41f4b71Sopenharmony_ci| US_ASCII        | 0X03   | US_ASCII格式        |
2180e41f4b71Sopenharmony_ci| UTF_8           | 0X6A   | UTF_8格式           |
2181e41f4b71Sopenharmony_ci
2182e41f4b71Sopenharmony_ci## DispositionType<sup>8+</sup>
2183e41f4b71Sopenharmony_ci
2184e41f4b71Sopenharmony_ci处理类型。
2185e41f4b71Sopenharmony_ci
2186e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2187e41f4b71Sopenharmony_ci
2188e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2189e41f4b71Sopenharmony_ci
2190e41f4b71Sopenharmony_ci|    名称    | 值   | 说明     |
2191e41f4b71Sopenharmony_ci| ---------- | ---- | -------- |
2192e41f4b71Sopenharmony_ci| FROM_DATA  | 0    | 数据来源 |
2193e41f4b71Sopenharmony_ci| ATTACHMENT | 1    | 附件     |
2194e41f4b71Sopenharmony_ci| INLINE     | 2    | 内联     |
2195e41f4b71Sopenharmony_ci
2196e41f4b71Sopenharmony_ci## ReportType<sup>8+</sup>
2197e41f4b71Sopenharmony_ci
2198e41f4b71Sopenharmony_ci报告类型。
2199e41f4b71Sopenharmony_ci
2200e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2201e41f4b71Sopenharmony_ci
2202e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2203e41f4b71Sopenharmony_ci
2204e41f4b71Sopenharmony_ci|  名称   | 值   | 说明 |
2205e41f4b71Sopenharmony_ci| ------- | ---- | ---- |
2206e41f4b71Sopenharmony_ci| MMS_YES | 128  | YES  |
2207e41f4b71Sopenharmony_ci| MMS_NO  | 129  | NO   |
2208e41f4b71Sopenharmony_ci
2209e41f4b71Sopenharmony_ci## CBConfigOptions<sup>7+</sup>
2210e41f4b71Sopenharmony_ci
2211e41f4b71Sopenharmony_ci小区广播配置选项。
2212e41f4b71Sopenharmony_ci
2213e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2214e41f4b71Sopenharmony_ci
2215e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2216e41f4b71Sopenharmony_ci
2217e41f4b71Sopenharmony_ci|      名称      | 类型                 | 必填 | 说明         |
2218e41f4b71Sopenharmony_ci| -------------- | -------------------- | ---- | ------------ |
2219e41f4b71Sopenharmony_ci| slotId         | number               | 是   | 卡槽ID       |
2220e41f4b71Sopenharmony_ci| enable         | boolean              | 是   | 可行         |
2221e41f4b71Sopenharmony_ci| startMessageId | number               | 是   | 消息起始ID   |
2222e41f4b71Sopenharmony_ci| endMessageId   | number               | 是   | 消息结束ID   |
2223e41f4b71Sopenharmony_ci| ranType        | [RanType](#rantype7) | 是   | 设备网络制式 |
2224e41f4b71Sopenharmony_ci
2225e41f4b71Sopenharmony_ci## SimMessageStatus<sup>7+</sup>
2226e41f4b71Sopenharmony_ci
2227e41f4b71Sopenharmony_ciSIM卡消息状态。
2228e41f4b71Sopenharmony_ci
2229e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2230e41f4b71Sopenharmony_ci
2231e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2232e41f4b71Sopenharmony_ci
2233e41f4b71Sopenharmony_ci|           名称            | 值   | 说明                        |
2234e41f4b71Sopenharmony_ci| ------------------------- | ---- | --------------------------- |
2235e41f4b71Sopenharmony_ci| SIM_MESSAGE_STATUS_FREE   | 0    | SIM卡上的可用空间状态       |
2236e41f4b71Sopenharmony_ci| SIM_MESSAGE_STATUS_READ   | 1    | 消息已读状态                |
2237e41f4b71Sopenharmony_ci| SIM_MESSAGE_STATUS_UNREAD | 3    | 消息未读状态                |
2238e41f4b71Sopenharmony_ci| SIM_MESSAGE_STATUS_SENT   | 5    | 存储发送消息(仅适用于SMS) |
2239e41f4b71Sopenharmony_ci| SIM_MESSAGE_STATUS_UNSENT | 7    | 存储未发送消息(仅适用于SMS) |
2240e41f4b71Sopenharmony_ci
2241e41f4b71Sopenharmony_ci## RanType<sup>7+</sup>
2242e41f4b71Sopenharmony_ci
2243e41f4b71Sopenharmony_ci设备网络制式。
2244e41f4b71Sopenharmony_ci
2245e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2246e41f4b71Sopenharmony_ci
2247e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2248e41f4b71Sopenharmony_ci
2249e41f4b71Sopenharmony_ci|   名称    | 值   | 说明 |
2250e41f4b71Sopenharmony_ci| --------- | ---- | ---- |
2251e41f4b71Sopenharmony_ci| TYPE_GSM  | 1    | GSM  |
2252e41f4b71Sopenharmony_ci| TYPE_CDMA | 2    | CMDA |
2253e41f4b71Sopenharmony_ci
2254e41f4b71Sopenharmony_ci## SmsEncodingScheme<sup>8+</sup>
2255e41f4b71Sopenharmony_ci
2256e41f4b71Sopenharmony_ci短信编码方案。
2257e41f4b71Sopenharmony_ci
2258e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2259e41f4b71Sopenharmony_ci
2260e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2261e41f4b71Sopenharmony_ci
2262e41f4b71Sopenharmony_ci|         名称         | 值   | 说明         |
2263e41f4b71Sopenharmony_ci| -------------------- | ---- | ------------ |
2264e41f4b71Sopenharmony_ci| SMS_ENCODING_UNKNOWN | 0    | 未知短信编码 |
2265e41f4b71Sopenharmony_ci| SMS_ENCODING_7BIT    | 1    | 7位短信编码  |
2266e41f4b71Sopenharmony_ci| SMS_ENCODING_8BIT    | 2    | 8位短信编码  |
2267e41f4b71Sopenharmony_ci| SMS_ENCODING_16BIT   | 3    | 16位短信编码 |
2268e41f4b71Sopenharmony_ci
2269e41f4b71Sopenharmony_ci## SimMessageOptions<sup>7+</sup>
2270e41f4b71Sopenharmony_ci
2271e41f4b71Sopenharmony_ciSIM卡消息选项。
2272e41f4b71Sopenharmony_ci
2273e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2274e41f4b71Sopenharmony_ci
2275e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2276e41f4b71Sopenharmony_ci
2277e41f4b71Sopenharmony_ci|  名称  | 类型                                   | 必填 | 说明           |
2278e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | ---- | -------------- |
2279e41f4b71Sopenharmony_ci| slotId | number                                 | 是   | 卡槽ID         |
2280e41f4b71Sopenharmony_ci| smsc   | string                                 | 是   | 短消息业务中心 |
2281e41f4b71Sopenharmony_ci| pdu    | string                                 | 是   | 协议数据单元   |
2282e41f4b71Sopenharmony_ci| status | [SimMessageStatus](#simmessagestatus7) | 是   | 状态           |
2283e41f4b71Sopenharmony_ci
2284e41f4b71Sopenharmony_ci## UpdateSimMessageOptions<sup>7+</sup>
2285e41f4b71Sopenharmony_ci
2286e41f4b71Sopenharmony_ci更新SIM卡消息选项。
2287e41f4b71Sopenharmony_ci
2288e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2289e41f4b71Sopenharmony_ci
2290e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2291e41f4b71Sopenharmony_ci
2292e41f4b71Sopenharmony_ci|   名称    | 类型                                   | 必填 | 说明           |
2293e41f4b71Sopenharmony_ci| --------- | -------------------------------------- | ---- | -------------- |
2294e41f4b71Sopenharmony_ci| slotId    | number                                 | 是   | 卡槽ID         |
2295e41f4b71Sopenharmony_ci| msgIndex  | number                                 | 是   | 消息索引       |
2296e41f4b71Sopenharmony_ci| newStatus | [SimMessageStatus](#simmessagestatus7) | 是   | 新状态         |
2297e41f4b71Sopenharmony_ci| pdu       | string                                 | 是   | 协议数据单元   |
2298e41f4b71Sopenharmony_ci| smsc      | string                                 | 是   | 短消息业务中心 |
2299e41f4b71Sopenharmony_ci
2300e41f4b71Sopenharmony_ci## SimShortMessage<sup>7+</sup>
2301e41f4b71Sopenharmony_ci
2302e41f4b71Sopenharmony_ciSIM卡短消息。
2303e41f4b71Sopenharmony_ci
2304e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2305e41f4b71Sopenharmony_ci
2306e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2307e41f4b71Sopenharmony_ci
2308e41f4b71Sopenharmony_ci|       名称       | 类型                                   | 必填 | 说明          |
2309e41f4b71Sopenharmony_ci| ---------------- | -------------------------------------- | ---- | ------------- |
2310e41f4b71Sopenharmony_ci| shortMessage     | [ShortMessage](js-apis-sms.md#shortmessage)          | 是   | 短消息        |
2311e41f4b71Sopenharmony_ci| simMessageStatus | [SimMessageStatus](#simmessagestatus7) | 是   | SIM卡消息状态 |
2312e41f4b71Sopenharmony_ci| indexOnSim       | number                                 | 是   | SIM卡索引     |
2313e41f4b71Sopenharmony_ci
2314e41f4b71Sopenharmony_ci## MmsDeliveryInd<sup>8+</sup>
2315e41f4b71Sopenharmony_ci
2316e41f4b71Sopenharmony_ci彩信发送标识。
2317e41f4b71Sopenharmony_ci
2318e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2319e41f4b71Sopenharmony_ci
2320e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2321e41f4b71Sopenharmony_ci
2322e41f4b71Sopenharmony_ci|    名称   | 类型                               | 必填 | 说明   |
2323e41f4b71Sopenharmony_ci| --------- | ---------------------------------- | ---- | ------ |
2324e41f4b71Sopenharmony_ci| messageId | string                             | 是   | 消息ID |
2325e41f4b71Sopenharmony_ci| date      | number                             | 是   | 日期   |
2326e41f4b71Sopenharmony_ci| to        | Array<[MmsAddress](#mmsaddress8)\> | 是   | 发送至 |
2327e41f4b71Sopenharmony_ci| status    | number                             | 是   | 状态   |
2328e41f4b71Sopenharmony_ci| version   | [MmsVersionType](#mmsversiontype8) | 是   | 版本   |
2329e41f4b71Sopenharmony_ci
2330e41f4b71Sopenharmony_ci## MmsRespInd<sup>8+</sup>
2331e41f4b71Sopenharmony_ci
2332e41f4b71Sopenharmony_ci彩信回复标志。
2333e41f4b71Sopenharmony_ci
2334e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2335e41f4b71Sopenharmony_ci
2336e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2337e41f4b71Sopenharmony_ci
2338e41f4b71Sopenharmony_ci|     名称      | 类型                               | 必填 | 说明     |
2339e41f4b71Sopenharmony_ci| ------------- | ---------------------------------- | ---- | -------- |
2340e41f4b71Sopenharmony_ci| transactionId | string                             | 是   | 事件ID   |
2341e41f4b71Sopenharmony_ci| status        | number                             | 是   | 状态     |
2342e41f4b71Sopenharmony_ci| version       | [MmsVersionType](#mmsversiontype8) | 是   | 版本     |
2343e41f4b71Sopenharmony_ci| reportAllowed | [ReportType](#reporttype8)         | 否   | 允许报告 |
2344e41f4b71Sopenharmony_ci
2345e41f4b71Sopenharmony_ci## SmsSegmentsInfo<sup>8+</sup>
2346e41f4b71Sopenharmony_ci
2347e41f4b71Sopenharmony_ci短信段信息。
2348e41f4b71Sopenharmony_ci
2349e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2350e41f4b71Sopenharmony_ci
2351e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.SmsMms
2352e41f4b71Sopenharmony_ci
2353e41f4b71Sopenharmony_ci|        名称          | 类型                                     | 必填 | 说明         |
2354e41f4b71Sopenharmony_ci| -------------------- | ---------------------------------------- | ---- | ------------ |
2355e41f4b71Sopenharmony_ci| splitCount           | number                                   | 是   | 拆分计数     |
2356e41f4b71Sopenharmony_ci| encodeCount          | number                                   | 是   | 编码计数     |
2357e41f4b71Sopenharmony_ci| encodeCountRemaining | number                                   | 是   | 剩余编码计数 |
2358e41f4b71Sopenharmony_ci| scheme               | [SmsEncodingScheme](#smsencodingscheme8) | 是   | 短信编码方案 |
2359