@ohos.telephony.sms (SMS) (System API)

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

NOTE

The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. This topic describes only system APIs provided by the module. For details about its public APIs, see @ohos.telephony.sms (SMS).

Modules to Import

import sms from '@ohos.telephony.sms';

sms.sendMms11+

sendMms(context: Context, mmsParams: MmsParams, callback: AsyncCallback<void>): void

Sends an MMS message. This API uses an asynchronous callback to return the result.

System API: This is a system API.

Required permissions: ohos.permission.SEND_MESSAGES

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
context Context Yes Application context.
For details about the application context of the FA model, see Context.
For details about the application context of the stage model, see Context.
mmsParams MmsParams Yes Parameters (including the callback) for sending MMS messages. For details, see MmsParams.
callback AsyncCallback<void> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

FA model:

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';
import common from '@ohos.app.ability.common';

// Obtain the context.
import featureAbility from '@ohos.ability.featureAbility';
let context: common.BaseContext = featureAbility.getContext();

// Configure the path for storing PDUs of MMS messages. Such PDUs are sent from the encoding API.
const sandBoxPath: string = '/data/storage/el2/base/files/';
let filePath: string  = sandBoxPath + 'SendReq.mms';

// Options for sending MMS messages (The MMSC is for reference only.)
let mmsPars: sms.MmsParams = {
  slotId : 0,
  mmsc: 'http://mmsc.myuni.com.cn',
  data: filePath,
  mmsConfig: {
   userAgent:'ua',
   userAgentProfile: 'uaprof'
  }
};

// Call the sendMms API.
sms.sendMms(context, mmsPars, async(err: BusinessError) =>{
  if (err) {
      console.error(`sendMms fail, err : ${JSON.stringify(err)}`);
      return;
  }
  console.log(`sendMms Success`);
})

Stage model:

import UIAbility from '@ohos.app.ability.UIAbility';
import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';
import window from '@ohos.window';

// Configure the path for storing PDUs of MMS messages. Such PDUs are sent from the encoding API.
const sandBoxPath = '/data/storage/el2/base/files/';
let filePath  = sandBoxPath + 'SendReq.mms';

// Configure the MMS user agent and profile. The default values are ua and uaprof, respectively. The configuration is subject to the carrier's requirements. 
let mmsConf: sms.MmsConfig = {
  userAgent:'ua',
  userAgentProfile: 'uaprof'
};

// Options for sending MMS messages (The MMSC is for reference only.)
let mmsPars: sms.MmsParams = {
  slotId : 0,
  mmsc: 'http://mmsc.myuni.com.cn',
  data: filePath,
  mmsConfig: mmsConf
};

class EntryAbility extends UIAbility {
    onWindowStageCreate(windowStage: window.WindowStage) {
    sms.sendMms(this.context, mmsPars, async(err: BusinessError) =>{
        if (err) {
            console.error(`sendMms fail, err : ${JSON.stringify(err)}`);
            return;
        }
        console.log(`sendMms Success`);
        })
    }
}

sms.sendMms11+

sendMms(context: Context, mmsParams: MmsParams): Promise<void>

Sends an MMS message. This API uses a promise to return the result.

System API: This is a system API.

Required permissions: ohos.permission.SEND_MESSAGES

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
context Context Yes Application context.
For details about the application context of the FA model, see Context.
For details about the application context of the stage model, see Context.
mmsParams MmsParams Yes Parameters (including the callback) for sending MMS messages. For details, see MmsParams.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

FA model:

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';
import common from '@ohos.app.ability.common';
// Obtain the context.
import featureAbility from '@ohos.ability.featureAbility';
let context: common.BaseContext = featureAbility.getContext();

// Configure the path for storing PDUs of MMS messages. Such PDUs are sent from the encoding API.
const sandBoxPath: string = '/data/storage/el2/base/files/';
let filePath: string = sandBoxPath + 'SendReq.mms';

// Options for sending MMS messages (The MMSC is for reference only.)
let mmsPars: sms.MmsParams = {
  slotId: 0,
  mmsc: 'http://mmsc.myuni.com.cn',
  data: filePath,
  mmsConfig: {
   userAgent:'ua',
   userAgentProfile: 'uaprof'
  }
};

// Call the sendMms API.
let promise = sms.sendMms(context, mmsPars);
promise.then(() => {
    console.log(`sendMms success`);
}).catch((err: BusinessError) => {
    console.error(`sendMms failed, promise: err->${JSON.stringify(err)}`);
});

Stage model:

import UIAbility from '@ohos.app.ability.UIAbility';
import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';
import window from '@ohos.window';

// Configure the path for storing PDUs of MMS messages. Such PDUs are sent from the encoding API.
const sandBoxPath = '/data/storage/el2/base/files/';
let filePath  = sandBoxPath + 'SendReq.mms';

// Configure the MMS user agent and profile. The default values are ua and uaprof, respectively. The configuration is subject to the carrier's requirements. 
let mmsConf: sms.MmsConfig = {
  userAgent:'ua',
  userAgentProfile: 'uaprof'
};

// Options for sending MMS messages (The MMSC is for reference only.)
let mmsPars: sms.MmsParams = {
  slotId : 0,
  mmsc: 'http://mmsc.myuni.com.cn',
  data: filePath,
  mmsConfig: mmsConf
};

class EntryAbility extends UIAbility {
    onWindowStageCreate(windowStage: window.WindowStage) {
    let promise = sms.sendMms(this.context, mmsPars);
    promise.then(() => {
        console.log(`sendMms success`);
    }).catch((err: BusinessError) => {
        console.error(`sendMms failed, promise: err->${JSON.stringify(err)}`);
    });
    }
}

sms.downloadMms11+

downloadMms(context: Context, mmsParams: MmsParams, callback: AsyncCallback<void>): void

Downloads an MMS message. This API uses an asynchronous callback to return the result.

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_MMS

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
context Context Yes Application context.
For details about the application context of the FA model, see Context.
For details about the application context of the stage model, see Context.
mmsParams MmsParams Yes Parameters (including the callback) for downloading MMS messages. For details, see MmsParams.
callback AsyncCallback<void> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

FA model:

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';
import common from '@ohos.app.ability.common';
// Obtain the context.
import featureAbility from '@ohos.ability.featureAbility';
let context: common.BaseContext = featureAbility.getContext();

// Configure the path for storing the PDU of the MMS message.
const sandBoxPath: string = '/data/storage/el2/base/files/';
let filePath: string = sandBoxPath + 'RetrieveConf.mms';

// Parse the MMS URL from the WAP Push message.
let wapPushUrl: string = 'URL';

// Configure the parameters (including the callback) for downloading MMS messages.
let mmsPars: sms.MmsParams = {
  slotId: 0,
  mmsc: wapPushUrl,
  data: filePath,
  mmsConfig: {
   userAgent:'ua',
   userAgentProfile: 'uaprof'
  }
};

// Call the downloadMms API.
sms.downloadMms(context, mmsPars, async(err: BusinessError) =>{
  if (err) {
      console.error(`downloadMms fail, err : ${JSON.stringify(err)}`);
      return;
  }
  console.log(`downloadMms Success`);
})

Stage model:

import UIAbility from '@ohos.app.ability.UIAbility';
import mms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';
import window from '@ohos.window';

// Configure the path for storing the PDU of the MMS message.
const sandBoxPath = '/data/storage/el2/base/files/';
let filePath  = sandBoxPath + 'RetrieveConf.mms';

// Parse the MMS URL from the WAP Push message.
let wapPushUrl  = 'URL';

// Configure the MMS user agent and profile. The default values are ua and uaprof, respectively. The configuration is subject to the carrier's requirements. 
let mmsConf: mms.MmsConfig = {
  userAgent:'ua',
  userAgentProfile: 'uaprof'
};

// Configure the parameters (including the callback) for downloading MMS messages.
let mmsPars: mms.MmsParams = {
  slotId : 0,
  mmsc: wapPushUrl,
  data: filePath,
  mmsConfig: mmsConf
};

class EntryAbility extends UIAbility {
    onWindowStageCreate(windowStage: window.WindowStage) {
    mms.downloadMms(this.context, mmsPars, async(err: BusinessError) =>{
        if (err) {
            console.error(`downloadMms fail, err : ${JSON.stringify(err)}`);
            return;
        }
        console.log(`downloadMms Success`);
        });
    }
}

sms.downloadMms11+

downloadMms(context: Context, mmsParams: MmsParams): Promise<void>

Sends an MMS message. This API uses a promise to return the result.

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_MMS

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
context Context Yes Application context.
For details about the application context of the FA model, see Context.
For details about the application context of the stage model, see Context.
mmsParams MmsParams Yes Parameters (including the callback) for sending MMS messages. For details, see MmsParams.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

FA model:

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';
import common from '@ohos.app.ability.common';
// Obtain the context.
import featureAbility from '@ohos.ability.featureAbility';
let context: common.BaseContext = featureAbility.getContext();

// Configure the path for storing the PDU of the MMS message.
const sandBoxPath: string = '/data/storage/el2/base/files/';
let filePath: string = sandBoxPath + 'RetrieveConf.mms';

// Parse the MMS URL from the WAP Push message.
let wapPushUrl: string = 'URL';

// Configure the parameters (including the callback) for downloading MMS messages.
let mmsPars: sms.MmsParams = {
  slotId: 0,
  mmsc: wapPushUrl,
  data: filePath,
  mmsConfig: {
   userAgent:'ua',
   userAgentProfile: 'uaprof'
  }
};

// Call the sendMms API.
let promise = sms.downloadMms(context, mmsPars);
promise.then(() => {
    console.log(`downloadMms success`);
}).catch((err: BusinessError) => {
    console.error(`downloadMms failed, promise: err->${JSON.stringify(err)}`);
});

Stage model:

import UIAbility from '@ohos.app.ability.UIAbility';
import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';
import window from '@ohos.window';

// Configure the path for storing the PDU of the MMS message.
const sandBoxPath = '/data/storage/el2/base/files/';
let filePath  = sandBoxPath + 'RetrieveConf.mms';

// Parse the MMS URL from the WAP Push message.
let wapPushUrl  = 'URL';

// Configure the MMS user agent and profile. The default values are ua and uaprof, respectively. The configuration is subject to the carrier's requirements. 
let mmsConf: sms.MmsConfig = {
  userAgent:'ua',
  userAgentProfile: 'uaprof'
};

// Configure the parameters (including the callback) for downloading MMS messages.
let mmsPars: sms.MmsParams = {
  slotId : 0,
  mmsc: wapPushUrl,
  data: filePath,
  mmsConfig: mmsConf
};

class EntryAbility extends UIAbility {
    onWindowStageCreate(windowStage: window.WindowStage) {
    let promise = sms.downloadMms(this.context, mmsPars);
    promise.then(() => {
        console.log(`downloadMms success`);
    }).catch((err: BusinessError) => {
        console.error(`downloadMms failed, promise: err->${JSON.stringify(err)}`);
    });
    }
}

sms.setDefaultSmsSlotId7+

setDefaultSmsSlotId(slotId: number, callback: AsyncCallback<void>): void

Sets the default slot ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.

System API: This is a system API.

Required permissions: ohos.permission.SET_TELEPHONY_STATE

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
- -1: Clears the default configuration.
callback AsyncCallback<void> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300004 Do not have sim card.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

sms.setDefaultSmsSlotId(0, (err: BusinessError) => {
    console.log(`callback: err->${JSON.stringify(err)}.`);
});

sms.setDefaultSmsSlotId7+

setDefaultSmsSlotId(slotId: number): Promise<void>

Sets the default slot ID of the SIM card used to send SMS messages. This API uses a promise to return the result.

System API: This is a system API.

Required permissions: ohos.permission.SET_TELEPHONY_STATE

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
- -1: Clears the default configuration.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300004 Do not have sim card.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

sms.setDefaultSmsSlotId(0).then(() => {
    console.log(`setDefaultSmsSlotId success.`);
}).catch((err: BusinessError) => {
    console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
});

sms.setSmscAddr7+

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

Sets the short message service center (SMSC) address. This API uses an asynchronous callback to return the result.

System API: This is a system API.

Required permissions: ohos.permission.SET_TELEPHONY_STATE (a system permission)

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
smscAddr string Yes SMSC address.
callback AsyncCallback<void> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
let smscAddr: string = '+861xxxxxxxxxx';
sms.setSmscAddr(slotId, smscAddr, (err: BusinessError) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
});

sms.setSmscAddr7+

setSmscAddr(slotId: number, smscAddr: string): Promise<void>

Sets the SMSC address. This API uses a promise to return the result.

System API: This is a system API.

Required permissions: ohos.permission.SET_TELEPHONY_STATE (a system permission)

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
smscAddr string Yes SMSC address.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
let smscAddr: string = '+861xxxxxxxxxx';
sms.setSmscAddr(slotId, smscAddr).then(() => {
    console.log(`setSmscAddr success.`);
}).catch((err: BusinessError) => {
    console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`);
});

sms.getSmscAddr7+

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

Obtains the SMSC address. This API uses an asynchronous callback to return the result.

System API: This is a system API.

Required permissions: ohos.permission.GET_TELEPHONY_STATE (a system permission)

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
callback AsyncCallback<string> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
sms.getSmscAddr(slotId, (err: BusinessError, data: string) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});

sms.getSmscAddr7+

getSmscAddr(slotId: number): Promise<string>

Obtains the SMSC address. This API uses a promise to return the result.

System API: This is a system API.

Required permissions: ohos.permission.GET_TELEPHONY_STATE (a system permission)

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2

Return value

Type Description
Promise<string> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
sms.getSmscAddr(slotId).then((data: string) => {
    console.log(`getSmscAddr success, promise: data->${JSON.stringify(data)}`);
}).catch((err: BusinessError) => {
    console.error(`getSmscAddr failed, promise: err->${JSON.stringify(err)}`);
});

sms.splitMessage8+

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

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

System API: This is a system API.

Required permissions: ohos.permission.SEND_MESSAGES

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
content string Yes SMS message content. The value cannot be null.
callback AsyncCallback<Array<string>> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let content: string = "long message";
sms.splitMessage(content, (err: BusinessError, data: string[]) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});

sms.splitMessage8+

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

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

System API: This is a system API.

Required permissions: ohos.permission.SEND_MESSAGES

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
content string Yes SMS message content. The value cannot be null.

Return value

Type Description
Promise<Array<string>> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let content: string = "long message";
let promise = sms.splitMessage(content);
promise.then((data: string[]) => {
    console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`);
}).catch((err: BusinessError) => {
    console.error(`splitMessage failed, promise: err->${JSON.stringify(err)}`);
});

sms.addSimMessage7+

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

Adds a message to the SIM card. If the SIM card is full, an error is reported. This API uses an asynchronous callback to return the result.

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
options SimMessageOptions Yes SIM message options.
callback AsyncCallback<void> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let simMessageOptions: sms.SimMessageOptions = {
    slotId: 0,
    smsc: "test",
    pdu: "xxxxxx",
    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
};
sms.addSimMessage(simMessageOptions, (err: BusinessError) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
});

sms.addSimMessage7+

addSimMessage(options: SimMessageOptions): Promise<void>

Adds a message to the SIM card. If the SIM card is full, an error is reported. This API uses a promise to return the result.

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
options SimMessageOptions Yes SIM message options.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let simMessageOptions: sms.SimMessageOptions = {
    slotId: 0,
    smsc: "test",
    pdu: "xxxxxx",
    status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
};
sms.addSimMessage(simMessageOptions).then(() => {
    console.log(`addSimMessage success.`);
}).catch((err: BusinessError) => {
    console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`);
});

sms.delSimMessage7+

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

Deletes a message from the SIM card. If the specified msgIndex is invalid, an error is reported. This API uses an asynchronous callback to return the result.

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
msgIndex number Yes Message index.
callback AsyncCallback<void> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
let msgIndex: number = 1;
sms.delSimMessage(slotId, msgIndex, (err: BusinessError) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
});

sms.delSimMessage7+

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

Deletes a message from the SIM card. If the specified msgIndex is invalid, an error is reported. This API uses a promise to return the result.

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
msgIndex number Yes Message index.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
let msgIndex: number = 1;
let promise = sms.delSimMessage(slotId, msgIndex);
promise.then(() => {
    console.log(`delSimMessage success.`);
}).catch((err: BusinessError) => {
    console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`);
});

sms.updateSimMessage7+

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

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

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
options UpdateSimMessageOptions Yes SIM message updating options.
callback AsyncCallback<void> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let updateSimMessageOptions: sms.UpdateSimMessageOptions = {
    slotId: 0,
    msgIndex: 1,
    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
    pdu: "xxxxxxx",
    smsc: "test"
};
sms.updateSimMessage(updateSimMessageOptions, (err: BusinessError) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
});

sms.updateSimMessage7+

updateSimMessage(options: UpdateSimMessageOptions): Promise<void>

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

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
options UpdateSimMessageOptions Yes SIM message updating options.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let updateSimMessageOptions: sms.UpdateSimMessageOptions = {
    slotId: 0,
    msgIndex: 1,
    newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
    pdu: "xxxxxxx",
    smsc: "test"
};
let promise = sms.updateSimMessage(updateSimMessageOptions);
promise.then(() => {
    console.log(`updateSimMessage success.`);
}).catch((err: BusinessError) => {
    console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`);
});

sms.getAllSimMessages7+

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

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

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_SMS

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
callback AsyncCallback<Array<SimShortMessage>> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
sms.getAllSimMessages(slotId, (err: BusinessError, data: sms.SimShortMessage[]) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});

sms.getAllSimMessages7+

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

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

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_SMS

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2

Return value

Type Description
Promise<Array<SimShortMessage>> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
let promise = sms.getAllSimMessages(slotId);
promise.then((data: sms.SimShortMessage[]) => {
    console.log(`getAllSimMessages success, promise: data->${JSON.stringify(data)}`);
}).catch((err: BusinessError) => {
    console.error(`getAllSimMessages failed, promise: err->${JSON.stringify(err)}`);
});

sms.setCBConfig7+

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

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

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_SMS

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
options CBConfigOptions Yes Cell broadcast configuration options.
callback AsyncCallback<void> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let cbConfigOptions: sms.CBConfigOptions = {
    slotId: 0,
    enable: true,
    startMessageId: 100,
    endMessageId: 200,
    ranType: sms.RanType.TYPE_GSM
};
sms.setCBConfig(cbConfigOptions, (err: BusinessError) => {
      console.log(`callback: err->${JSON.stringify(err)}`);
});

sms.setCBConfig7+

setCBConfig(options: CBConfigOptions): Promise<void>

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

System API: This is a system API.

Required permissions: ohos.permission.RECEIVE_SMS

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
options CBConfigOptions Yes Cell broadcast configuration options.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let cbConfigOptions: sms.CBConfigOptions = {
    slotId: 0,
    enable: true,
    startMessageId: 100,
    endMessageId: 200,
    ranType: sms.RanType.TYPE_GSM
};
let promise = sms.setCBConfig(cbConfigOptions);
promise.then(() => {
    console.log(`setCBConfig success.`);
}).catch((err: BusinessError) => {
    console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`);
});

sms.getSmsSegmentsInfo8+

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

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

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
message string Yes SMS message.
force7bit boolean Yes Whether to use 7-bit coding.
callback AsyncCallback<SmsSegmentsInfo> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
sms.getSmsSegmentsInfo(slotId, "message", false, (err: BusinessError, data: sms.SmsSegmentsInfo) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});

sms.getSmsSegmentsInfo8+

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

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

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
message string Yes SMS message.
force7bit boolean Yes Whether to use 7-bit coding.

Return value

Type Description
Promise<SmsSegmentsInfo> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
let promise = sms.getSmsSegmentsInfo(slotId, "message", false);
promise.then((data: sms.SmsSegmentsInfo) => {
    console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`);
}).catch((err: BusinessError) => {
    console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`);
});

sms.isImsSmsSupported8+

isImsSmsSupported(slotId: number, callback: AsyncCallback<boolean>): void

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

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes SIM card slot ID.
- 0: card slot 1
- 1: card slot 2
callback AsyncCallback<boolean> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
sms.isImsSmsSupported(slotId, (err: BusinessError, data: boolean) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});

sms.isImsSmsSupported8+

isImsSmsSupported(slotId: number): Promise<boolean>

Checks whether SMS is supported on IMS. This API uses a promise to return the result.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
slotId number Yes Card slot ID.
- 0: card slot 1
- 1: card slot 2

Return value

Type Description
Promise<boolean> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let slotId: number = 0;
let promise = sms.isImsSmsSupported(slotId);
promise.then((data: boolean) => {
    console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`);
}).catch((err: BusinessError) => {
    console.error(`isImsSmsSupported failed, promise: err->${JSON.stringify(err)}`);
});

sms.getImsShortMessageFormat8+

getImsShortMessageFormat(callback: AsyncCallback<string>): void

Obtains the SMS format supported by the IMS, for example, 3gpp, 3gpp2, or unknown. This API uses an asynchronous callback to return the result.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
callback AsyncCallback<string> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

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

sms.getImsShortMessageFormat8+

getImsShortMessageFormat(): Promise<string>

Obtains the SMS format supported by the IMS, for example, 3gpp, 3gpp2, or unknown. This API uses a promise to return the result.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Return value

Type Description
Promise<string> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
202 Non-system applications use system APIs.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

sms.getImsShortMessageFormat().then((data: string) => {
    console.log(`getImsShortMessageFormat success, promise: data->${JSON.stringify(data)}`);
}).catch((err: BusinessError) => {
    console.error(`getImsShortMessageFormat failed, promise: err->${JSON.stringify(err)}`);
});

sms.decodeMms8+

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

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

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
mmsFilePathName string |Array<number> Yes MMS message file path.
callback AsyncCallback<MmsInformation> Yes Callback used to return the result, which is carried in {@code MmsInformation}.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let mmsFilePathName: string = "filename";
sms.decodeMms(mmsFilePathName, (err: BusinessError, data: sms.MmsInformation) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});

const 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];
sms.decodeMms(mmsPdu, (err: BusinessError, data: sms.MmsInformation) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});

sms.decodeMms8+

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

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

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
mmsFilePathName string |Array<number> Yes MMS message file path.

Return value

Type Description
Promise<<MmsInformation>> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let mmsFilePathName: string = "filename";
let promise = sms.decodeMms(mmsFilePathName);
promise.then((data: sms.MmsInformation) => {
    console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch((err: BusinessError) => {
    console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`);
});

const 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];
let promiseArr = sms.decodeMms(mmsPdu);
promiseArr.then((data: sms.MmsInformation) => {
    console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch((err: BusinessError) => {
    console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`);
});

sms.encodeMms8+

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

MMS message code. This API uses an asynchronous callback to return the result.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
mms MmsInformation Yes MMS message information.
callback AsyncCallback<Array<number>> Yes Callback used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let mmsAcknowledgeInd: sms.MmsAcknowledgeInd = {
    transactionId: "100",
    version: sms.MmsVersionType.MMS_VERSION_1_0,
    reportAllowed: sms.ReportType.MMS_YES
};
let mmsInformation: sms.MmsInformation = {
    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
    mmsType: mmsAcknowledgeInd
};
sms.encodeMms(mmsInformation, (err: BusinessError, data: number[]) => {
      console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});

sms.encodeMms8+

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

MMS message code. This API uses a promise to return the result.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Parameters

Name Type Mandatory Description
mms MmsInformation Yes MMS message information.

Return value

Type Description
Promise<Array<number>> Promise used to return the result.

Error codes

For details about the error codes, see Telephony Error Codes.

ID Error Message
202 Non-system applications use system APIs.
401 Parameter error.
8300001 Invalid parameter value.
8300002 Operation failed. Cannot connect to service.
8300003 System internal error.
8300999 Unknown error code.

Example

import sms from '@ohos.telephony.sms';
import { BusinessError } from '@ohos.base';

let mmsAcknowledgeInd: sms.MmsAcknowledgeInd = {
    transactionId: "100",
    version: sms.MmsVersionType.MMS_VERSION_1_0,
    reportAllowed: sms.ReportType.MMS_YES
};
let mmsInformation: sms.MmsInformation = {
    messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
    mmsType: mmsAcknowledgeInd
};
sms.encodeMms(mmsInformation).then((data: number[]) => {
    console.log(`encodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch((err: BusinessError) => {
    console.error(`encodeMms failed, promise: err->${JSON.stringify(err)}`);
});

MmsParams11+

Defines the parameters for sending SMS messages.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
slotId11+ number Yes Slot ID of the SIM card used for sending SMS messages.
- 0: card slot 1
- 1: card slot 2
mmsc11+ string Yes MMSC address.
data11+ string Yes MMS PDU address.
mmsConfig11+ MmsConfig No MMS configuration file. For details, see MmsParams.

MmsConfig11+

MMS configuration file.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
userAgent11+ string Yes User agent.
userAgentProfile11+ string Yes User agent profile.

MmsInformation8+

Defines the MMS message information.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
messageType MessageType Yes Message type.
mmsType MmsSendReq |MmsSendConf |MmsNotificationInd |MmsRespInd |MmsRetrieveConf|MmsAcknowledgeInd|MmsDeliveryInd|MmsReadOrigInd|MmsReadRecInd Yes PDU header type.
attachment Array<MmsAttachment> No Attachment.

MmsSendReq8+

Defines an MMS message sending request.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
from MmsAddress Yes MMS message source.
transactionId string Yes Transaction ID.
contentType string Yes Content type.
version MmsVersionType Yes Version.
to Array<MmsAddress> No Destination address.
date number No Date.
cc Array<MmsAddress> No Carbon copy.
bcc Array<MmsAddress> No Blind carbon copy.
subject string No Subject.
messageClass number No Message class.
expiry number No Expiration.
priority MmsPriorityType No Priority.
senderVisibility number No Sender visibility.
deliveryReport number No Delivery report.
readReport number No Read report.

MmsSendConf8+

Defines the MMS message sending configuration.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
responseState number Yes Response status.
transactionId string Yes Transaction ID.
version MmsVersionType Yes Version.
messageId string No Message ID.

MmsNotificationInd8+

Defines an MMS notification index.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
transactionId string Yes Transaction ID.
messageClass number Yes Message class.
messageSize number Yes Message size.
expiry number Yes Expiration.
contentLocation string Yes Content location.
version MmsVersionType Yes Version.
from MmsAddress No Source address.
subject string No Subject.
deliveryReport number No Status report.
contentClass number No Content class.

MmsAcknowledgeInd8+

Defines an MMS confirmation index.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
transactionId string Yes Transaction ID.
version MmsVersionType Yes Version.
reportAllowed ReportType No Report allowed.

MmsRetrieveConf8+

Defines the MMS message retrieval configuration.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
transactionId string Yes Transaction ID.
messageId string Yes Message ID.
date number Yes Date.
contentType string Yes Content type.
to Array<MmsAddress> Yes Destination address.
version MmsVersionType Yes Version.
from MmsAddress No Source address.
cc Array<MmsAddress> No Carbon copy.
subject string No Subject.
priority MmsPriorityType No Priority.
deliveryReport number No Status report.
readReport number No Read report.
retrieveStatus number No Retrieval status.
retrieveText string No Retrieval text.

MmsReadOrigInd8+

Defines the original MMS message reading index.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
version MmsVersionType Yes Version.
messageId string Yes Message ID.
to Array<MmsAddress> Yes Destination address.
from MmsAddress Yes Source address.
date number Yes Date.
readStatus number Yes Read status.

MmsReadRecInd8+

Defines the MMS message reading index.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
version MmsVersionType Yes Version.
messageId string Yes Message ID.
to Array<MmsAddress> Yes Destination address.
from MmsAddress Yes Source address.
readStatus number Yes Read status.
date number No Date.

MmsAttachment8+

Defines the attachment of an MMS message.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
contentId string Yes Content ID.
contentLocation string Yes Content location.
contentDisposition DispositionType Yes Content disposition.
contentTransferEncoding string Yes Encoding for content transfer.
contentType string Yes Content type.
isSmil boolean Yes Whether the synchronized multimedia integration language is used.
path string No Path.
inBuff Array<number> No Whether the message is in the buffer.
fileName string No File name.
charset MmsCharSets No Character set.

MmsAddress8+

Defines an MMSC address.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
address string Yes Network address.
charset MmsCharSets Yes Character set.

MessageType8+

Message type.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Value Description
TYPE_MMS_SEND_REQ 128 MMS message sending request.
TYPE_MMS_SEND_CONF 129 MMS message sending configuration.
TYPE_MMS_NOTIFICATION_IND 130 MMS notification index.
TYPE_MMS_RESP_IND 131 MMS message response index.
TYPE_MMS_RETRIEVE_CONF 132 MMS message retrieval configuration.
TYPE_MMS_ACKNOWLEDGE_IND 133 MMS message acknowledgement index.
TYPE_MMS_DELIVERY_IND 134 MMS message delivery index.
TYPE_MMS_READ_REC_IND 135 MMS message reading and receiving index.
TYPE_MMS_READ_ORIG_IND 136 Original MMS message reading index.

MmsPriorityType8+

Enumerates MMS message priorities.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Value Description
MMS_LOW 128 Low priority.
MMS_NORMAL 129 Normal priority.
MMS_HIGH 130 High priority.

MmsVersionType8+

Enumerates MMS versions.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Value Description
MMS_VERSION_1_0 0x10 MMS version 1_0.
MMS_VERSION_1_1 0x11 MMS version 1_1.
MMS_VERSION_1_2 0x12 MMS version 1_2.
MMS_VERSION_1_3 0x13 MMS version 1_3.

MmsCharSets8+

Enumerates MMS character sets.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Value Description
BIG5 0X07EA BIG5 format.
ISO_10646_UCS_2 0X03E8 ISO_10646_UCS_2 format.
ISO_8859_1 0X04 ISO_8859_1 format.
ISO_8859_2 0X05 ISO_8859_2 format.
ISO_8859_3 0X06 ISO_8859_3 format.
ISO_8859_4 0X07 ISO_8859_4 format.
ISO_8859_5 0X08 ISO_8859_5 format.
ISO_8859_6 0X09 ISO_8859_6 format.
ISO_8859_7 0X0A ISO_8859_7 format.
ISO_8859_8 0X0B ISO_8859_8 format.
ISO_8859_9 0X0C ISO_8859_9 format.
SHIFT_JIS 0X11 SHIFT_JIS format.
US_ASCII 0X03 US_ASCII format.
UTF_8 0X6A UTF_8 format.

DispositionType8+

Enumerates disposition types.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Value Description
FROM_DATA 0 Data source.
ATTACHMENT 1 Attachment.
INLINE 2 Inlining.

ReportType8+

Enumerates report types.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Value Description
MMS_YES 128 YES
MMS_NO 129 NO

CBConfigOptions7+

Defines the cell broadcast configuration options.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
slotId number Yes Card slot ID.
enable boolean Yes Whether to enable cell broadcast.
startMessageId number Yes Start message ID.
endMessageId number Yes End message ID.
ranType RanType Yes RAN type.

SimMessageStatus7+

Defines the SIM message status.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Value Description
SIM_MESSAGE_STATUS_FREE 0 Free space state of the SIM card.
SIM_MESSAGE_STATUS_READ 1 Read state.
SIM_MESSAGE_STATUS_UNREAD 3 Unread state.
SIM_MESSAGE_STATUS_SENT 5 Storage of sent messages (applicable only to SMS).
SIM_MESSAGE_STATUS_UNSENT 7 Storage of unsent messages (applicable only to SMS).

RanType7+

RAN type.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Value Description
TYPE_GSM 1 GSM
TYPE_CDMA 2 CMDA

SmsEncodingScheme8+

Enumerates SMS encoding schemes.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Value Description
SMS_ENCODING_UNKNOWN 0 Unknown code.
SMS_ENCODING_7BIT 1 7-digit code.
SMS_ENCODING_8BIT 2 8-digit code.
SMS_ENCODING_16BIT 3 16-digit code.

SimMessageOptions7+

Defines the SIM message options.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
slotId number Yes Card slot ID.
smsc string Yes Short message service center.
pdu string Yes Protocol data unit.
status SimMessageStatus Yes Status.

UpdateSimMessageOptions7+

Defines the updating SIM message options.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
slotId number Yes Card slot ID.
msgIndex number Yes Message index.
newStatus SimMessageStatus Yes New status.
pdu string Yes Protocol data unit.
smsc string Yes Short message service center.

SimShortMessage7+

Defines a SIM message.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
shortMessage ShortMessage Yes SMS message.
simMessageStatus SimMessageStatus Yes SIM message status.
indexOnSim number Yes SIM card index.

MmsDeliveryInd8+

Defines an MMS message delivery index.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
messageId string Yes Message ID.
date number Yes Date.
to Array<MmsAddress> Yes Destination address.
status number Yes Status.
version MmsVersionType Yes Version.

MmsRespInd8+

Defines an MMS response index.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
transactionId string Yes Event ID.
status number Yes Status.
version MmsVersionType Yes Version.
reportAllowed ReportType No Report allowed.

SmsSegmentsInfo8+

Defines the SMS message segment information.

System API: This is a system API.

System capability: SystemCapability.Telephony.SmsMms

Name Type Mandatory Description
splitCount number Yes Split count.
encodeCount number Yes Encoding count.
encodeCountRemaining number Yes Remaining encoding count.
scheme SmsEncodingScheme Yes Encoding scheme.