Search packages, repositories and app categories

Package detailsv0.0.4

background_sms

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.

AndroidiOS
30-day downloads
193
Likes
70
Pub points
140

Install package

flutter pub add background_sms

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The background_sms package enables sending SMS messages from the background or headless state of an app, regardless of whether the device is locked, the app is in the foreground, or running in the background. It is designed for use cases requiring reliable, automated SMS delivery without user interaction. The package supports both Android and iOS platforms, though functionality may vary between them due to platform-specific restrictions. It integrates with Flutter via a straightforward API, allowing developers to trigger SMS sending even when the app is not actively open.

Use cases

  • Automated OTP delivery
  • Emergency alert systems
  • Remote device control
  • Scheduled message broadcasting
  • Service status notifications

Key features

  • Background SMS sending
  • Headless execution support
  • Cross-platform (Android & iOS)
  • Simple API integration
  • Reliable message delivery

Suitable for

  • Apps needing silent SMS automation
  • Services requiring offline message triggers
  • IoT device communication
  • Security and monitoring applications

Considerations

  • iOS has limited background execution capabilities
  • Requires appropriate permissions and user consent
  • May be restricted by carrier policies
  • Not suitable for high-volume messaging
  • Depends on device manufacturer's SMS handling

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Background SMS

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

It only support Android for now.

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");
        }
    }

Platform Detail

Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git Framework • revision 77d935af4d (2 months ago) • 2021-12-16 08:37:33 -0800 Engine • revision 890a5fca2e Tools • Dart 2.15.1

Created by

Shine Wanna

Categories

Source repository

Projects using this package

No data available yet.