Is there a way to send SMS on flutter without user interaction?

Viewed 2658

I'm trying to send SMS from my flutter app when a button is pressed. I'd like to do this without user interaction. I know i can launch the SMS app using url_launcher.

I tried using the sms package from pub but flutter says the api is outdated.

I'd like to do this purely in dart if possible.

1 Answers

I'm using the package sms_maintained. refer to package for latest version.

Code sample from package.

import 'package:sms/sms.dart';

void main() {
  SmsSender sender = new SmsSender();
  String address = someAddress();
  ...
  sender.sendSms(new SmsMessage(address, 'Hello flutter!'));
}

I't provides other methods as well.

Querying, filtering, contact info, receiving and deleting as well.

For sending the a sms you'd need the necessary permissions.

  • SEND_SMS

And for other functionalities.

  • RECEIVE_SMS

  • READ_SMS

  • READ_CONTACTS

An extensive list of them are located here.

flutter AndroidManifest.xml is location => android/app/src/main/AndroidManifest.xml

EDIT #:

The package is no longer maintained. you may manually link to files from this repo

pubspec.yaml

dependencies:
  ...
  sms_maintained:
    path: plugin_folder_path
Related