5

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.

Mensch
  • 670
  • 7
  • 16
  • `I'd like to do this without user interaction. ` Sounds dodgy, if you have a sms provider you can do it using a REST service, but don't think it will be possible to send the sms from the user using his resources – Tinus Jackson Jul 02 '19 at 10:23
  • when i said `I'd like to do this without user interaction.`, i meant i want to send sms without opening another page like `flutter_sms` does. the primary function of the app would be to send an sms to a fixed number, i assume the users that install would know, since it would also ask for permission to send sms. – Mensch Jul 02 '19 at 10:28
  • @delphix me too, i need to find a way to send sms in the app without using another app. if you find a way please share it. – Reza Mojed May 18 '20 at 13:39
  • @DelphiX were you able to send SMS/MMS without user interaction? – Sunil D S Feb 05 '21 at 11:43
  • 1
    @SunilDS Yes i was, Its been a while since then. i forked the [repository](https://github.com/geordyvcErasmus/flutter_sms) and made the changes i required. while its regrettable that we dont have a more straight forward option. this gives a starting position. – Mensch Feb 06 '21 at 13:16

1 Answers1

0

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
Mensch
  • 670
  • 7
  • 16