background_sms 0.0.3

Flutter Android iOS

The main purpose is to send sms from background and headless.You can send sms whatever the phone state is in app or background or headless.

Background SMS #

This is an SMS library for flutter. You can send SMS from foreground, background, and headless.

It only support Android for now.

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Installation and Usage #

Add background_sms to the dependencies list of the pubspec.yaml file as follow:

dependencies:
  flutter:
    sdk: flutter

  background_sms: ^0.0.1

Then run the command flutter packages get on the console.

First add permission to send sms in AndroidManifest.xml.

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

Then request permission for send sms.Use Permission Handler or something other.

Import

import 'package:background_sms/background_sms.dart';

Simply send sms with default sim.

  String result = await BackgroundSms.sendMessage(
     phoneNumber: "09xxxxxxxxx", message: "Message");
    if (result == SmsStatus.sent) {
      print("Sent");
    } else {
      print("Failed");
    }

Send with custom sim slot 1 for sim1, 2 for sim2 and so on.

  String result = await BackgroundSms.sendMessage(
     phoneNumber: "09xxxxxxxxx", message: "Message", simSlot: 1);
    if (result == SmsStatus.sent) {
      print("Sent");
    } else {
      print("Failed");
    }

You can check Custom Sim Slot is support from Native Android.

  bool result = await BackgroundSms.isSupportCustomSim;
    if (result) {
      print("Support Custom Sim Slot");
        String result = await BackgroundSms.sendMessage(
        phoneNumber: "09xxxxxxxxx", message: "Message", simSlot: 1);
        if (result == SmsStatus.sent) {
          print("Sent");
        } else {
          print("Failed");
        }
    } else {
      print("Not Support Custom Sim Slot");
        String result = await BackgroundSms.sendMessage(
        phoneNumber: "09xxxxxxxxx", message: "Message");
        if (result == SmsStatus.sent) {
          print("Sent");
        } else {
          print("Failed");
        }
    }

Created by #

Shine Wanna

5
likes
90
pub points
47%
popularity

Publisher

midcarry.tk

The main purpose is to send sms from background and headless.You can send sms whatever the phone state is in app or background or headless.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache 2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on background_sms