Skip to main content

@napacitor/sms

SMS plugin wrapping the .NET MAUI Sms API: send text messages.

Installation​

To use npm:

npm install @napacitor/sms

To use yarn:

yarn add @napacitor/sms

Sync native files:

npx nap sync

Usage​

import { Sms } from '@napacitor/sms';

// Check for support
const { supported } = await Sms.isSupported();

if (supported) {
await Sms.send({
recipients: ['+8613800138000'],
body: 'Hello!',
});
}

How It Works​

Wraps the .NET MAUI Sms.Default.IsComposeSupported / ComposeAsync facade, opening the system SMS client. send() throws UNSUPPORTED when the device does not support it. Note: the plugin only invokes the system SMS client and does not provide background silent sending.

Permissions​

Android​

No additional configuration required (SMS goes through a system Intent, nothing is sent directly).

iOS​

No additional configuration required.

Windows​

No additional configuration required.

API​

isSupported()​

Checks whether sending SMS is supported.

Returns: Promise<SmsSupportedResult>

send(options)​

Sends an SMS (opens the system SMS client; throws UNSUPPORTED when the device does not support it).

ParamType
optionsSmsOptions

Returns: Promise<void>

Interfaces​

SmsOptions​

PropTypeDescription
recipientsstring[]Recipient phone numbers (must not be empty, otherwise INVALID_ARGUMENTS is thrown).
bodystringSMS body.

SmsSupportedResult​

PropTypeDescription
supportedbooleanWhether the current device supports sending SMS.