Telephony
  • Telephony
  • Permissions
  • Sending An SMS
  • Query SMS
  • Query Conversations
  • Listen Incoming SMS
  • Network Data and Metrics
  • Start Phone Call
  • Executing in Background
Powered by GitBook
On this page
  • sendSms()
  • sendSmsByDefaultApp()
  • SmsSendStatusListener
  • SendStatus

Was this helpful?

Sending An SMS

PreviousPermissionsNextQuery SMS

Last updated 4 years ago

Was this helpful?

Requires SEND_SMS permission.

Add the following permission in your AndroidManifest.xml

<uses-permission android:name="android.permission.SEND_SMS"/>

sendSms()

Returns Future<void>

Parameters

Type

Description

Optional

Default Value

to

String

Number to send SMS to

❌

-

message

String

Message to send

❌

-

isMultipart

bool

If the body of the message is longer than the standard SMS length limit of 160 characters, you can send a multipart SMS by setting the isMultipart flag.

✔️

false

statusListener

Receives SMS sent and delivered events

✔️

null

Telephony telephony = Telephony.instance;

await telephony.sendSms(
    to: "1234567890",
    message: "May the force be with you!"
    );

If you want to listen to the status of the message being sent, provide to the sendSms function.

final SmsSendStatusListener listener = (SendStatus status) {
    // Handle the status
    };

await telephony.sendSms(
    to: "1234567890",
    message: "May the force be with you!",
    statusListener: listener
    );

TIP: If you want to send an sms to multiple numbers, you may pass multiple numbers separated by a ;

await telephony.sendSms(
    to: "1234567890;5724352435;24653456345",
    message: "May the force be with you!"
    );

Keep in mind that this method may not work on all devices.

sendSmsByDefaultApp()

Returns Future<void>

Parameters

Type

Description

Optional

to

String

Number to send SMS to

❌

message

String

Message to send

❌

Opens the default SMS app with the number and the message passed to the function.

await telephony.sendSmsByDefaultApp(
    to: "1234567890",
    message: "May the force be with you!"
    );

SmsSendStatusListener

Receives SendStatus when SMS is sent and delivered.

SmsSendStatusListener listener = (SendStatus status) {
    // Handle the status
    };

SendStatus

Type

Values

Enum

SENT, DELIVERED

SmsSendStatusListener
SmsSendStatusListener