sms_sender_background 1.0.6 copy "sms_sender_background: ^1.0.6" to clipboard
sms_sender_background: ^1.0.6 copied to clipboard

PlatformAndroid

A Flutter plugin for sending SMS messages with support for dual SIM cards, permission handling, and multi-part messages.

SMS Sender Background #

A Flutter plugin for sending SMS messages with support for dual SIM cards, permission handling, and multi-part messages.

Features #

  • Send SMS messages from your Flutter app
  • Support for dual SIM cards (specify SIM slot)
  • Automatic permission handling (request and check SMS permissions)
  • Support for long messages (automatically splits into multi-part messages)
  • Error handling and status reporting

Getting Started #

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  sms_sender_background: ^1.0.6
copied to clipboard

Android Setup #

Add the following permission to your Android Manifest (android/app/src/main/AndroidManifest.xml):

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

Usage #

import 'package:sms_sender_background/sms_sender.dart';;

// Create an instance
final smsSender = SmsSender();

// Check SMS permission
bool hasPermission = await smsSender.checkSmsPermission();

// Request permission if needed
if (!hasPermission) {
  hasPermission = await smsSender.requestSmsPermission();
}

// Send SMS
if (hasPermission) {
  try {
    bool success = await smsSender.sendSms(
      phoneNumber: '+1234567890',
      message: 'Hello from Flutter!',
      simSlot: 0, // Optional: specify SIM slot (0 or 1)
    );
    print('SMS sent: $success');
  } catch (e) {
    print('Error sending SMS: $e');
  }
}
copied to clipboard

Additional Features #

Dual SIM Support #

To send an SMS using a specific SIM card:

await smsSender.sendSms(
  phoneNumber: '+1234567890',
  message: 'Hello!',
  simSlot: 1, // Use second SIM card
);
copied to clipboard

Long Messages #

The plugin automatically handles long messages by splitting them into multiple parts:

await smsSender.sendSms(
  phoneNumber: '+1234567890',
  message: 'A very long message that will be automatically split...',
);
copied to clipboard

Error Handling #

The plugin provides detailed error information through exceptions:

  • PlatformException with code "PERMISSION_DENIED" when SMS permission is not granted
  • PlatformException with code "INVALID_ARGUMENT" when phone number or message is empty
  • PlatformException with code "SMS_SEND_ERROR" when SMS sending fails

Contributing #

Feel free to contribute to this project:

  1. Fork it
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-new-feature)
  5. Create a new Pull Request

License #

This project is licensed under the MIT License - see the LICENSE file for details

6
likes
150
points
117
downloads

Publisher

unverified uploader

Weekly Downloads

2024.10.05 - 2025.04.19

A Flutter plugin for sending SMS messages with support for dual SIM cards, permission handling, and multi-part messages.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on sms_sender_background