Twilio Flutter

A Dart package for both android and iOS which helps developers with Twilio API services. This Dart Package can be integrated into any Flutter application to make use of Twilio API.

Features

  • Send SMS programmatically
  • Get all SMS related to a Twilio account
  • Get more info on each SMS sent from a Twilio account
  • Send WhatsApp messages programmatically
  • Send Scheduled SMS
  • Cancel Scheduled SMS
  • Send Scheduled WhatsApp message
  • Cancel Scheduled WhatsApp Message

Getting Started

Check out our comprehensive Example provided with this plugin.

To use this package :

  • add the dependency to your pubspec.yaml file.
dependencies:
  flutter:
    sdk: flutter
  twilio_flutter: ^0.3.0

How to use

Please find the following values from Twilio Console:

  • accountSid
  • Twilio Number
  • Auth Token
  • Messaging Service Sid (Optional, required for features like scheduled messages)

Create a new Object and Initialize with values

final TwilioFlutter twilioFlutter = TwilioFlutter(
accountSid : '', // replace with Account SID
authToken : '', // replace with Auth Token
twilioNumber:'', // replace with Twilio Number(With country code)
messagingServiceSid:'' // optional replace with messaging service sid, required for features like scheduled sms
);

Send SMS

Use sendSMS with the recipient number and message body.

await twilioFlutter.sendSMS(
toNumber : '',// replace with Mobile Number(With country code)
messageBody : 'hello world');

View SMS List


final data = await twilioFlutter.getSmsList({String pageSize}); //Returns list of SMS , pageSize defaults to 20

View Single SMS


final data = await twilioFlutter.getSMS(String messageSID); //Use message sid from the individual messages.

Change Twilio Number

twilioFlutter.changeTwilioNumber(''); // To change the twilio number(With country code)

Send WhatsApp Message

await twilioFlutter.sendWhatsApp(toNumber : '',// replace with Mobile Number(With country code)
messageBody : 'hello world');

Send Scheduled SMS Message

Scheduled messages can be sent if the sendAt is at least 15 after the current time.

await twilioFlutter.sendScheduledSms(
toNumber : '',
messageBody : 'hello world',
sendAt:'2024-02-18T16:18:55Z'// Datetime has to be in the same format
);

Cancel Scheduled SMS

Scheduled SMS can be cancelled using the messageSid.

await twilioFlutter.cancelScheduledSms(messageSID: '');

Send Scheduled WhatsApp Message

Scheduled messages can be sent if the sendAt is at least 15 after the current time.

await twilioFlutter.sendScheduledWhatsAppMessage(
toNumber : '',
messageBody : 'hello world',
sendAt:'2024-02-18T16:18:55Z'// Datetime has to be in the same format
);

Cancel Scheduled WhatsApp Message

Scheduled whatsapp messages can be cancelled using the messageSid.

await twilioFlutter.cancelScheduledWhatsAppMessage(messageSID: '');

Future Features

  • x Cancel Scheduled Messages
  • Email Sending Support
  • Update a Message resource
  • Delete a Message resource
  • Alphanumeric Sender IDs in Messaging Services
  • More Support for Messaging Service
  • Send message through Facebook Messenger

Supported Platforms

  • Android
  • iOS
  • Web
  • MacOs
  • Windows
  • Linux

Useful articles

Issues

Please file any issues, bugs or feature requests as an issue on our GitHub page.

Want to contribute

If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.

Author

This Twilio Flutter plugin for Flutter is developed by Adarsh Balachandran.

Libraries

twilio_flutter