๐Ÿ“ฉ sms_controller

A Flutter plugin to read and send SMS messages on Android and send SMS using the default messaging app on iOS.


โœจ Features

  • ๐Ÿ“ค Send SMS on Android (background)
  • ๐Ÿ“ฅ Read inbox SMS messages (Android only)
  • ๐Ÿ“ค Launch native SMS composer on iOS (via UI)

๐Ÿš€ Getting Started

1. Add Dependency

Add this to your pubspec.yaml:

dependencies:
  sms_controller:
    git:
      url: https://github.com/Rajkumar07793/sms_controller.git

๐Ÿ“ฑ Platform Support

Feature Android iOS
Send SMS โœ… โœ… (UI only)
Read SMS Inbox โœ… โŒ Not Supported

๐Ÿ› ๏ธ Usage

import 'package:sms_controller/sms_controller.dart';

// Read inbox messages (Android only)
final List<Map<String, dynamic>> messages = await SmsController.getInboxSms();

// Send SMS
await SmsController.sendSms("1234567890", "Hello from Flutter!");

โ„น๏ธ On iOS, this will open the native messaging UI.


๐Ÿ”’ Permissions

Android

Add the following permissions to android/app/src/main/AndroidManifest.xml:

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

Use permission_handler to request runtime permissions.

iOS

Add this to your ios/Runner/Info.plist:

<key>NSContactsUsageDescription</key>
<string>This app needs access to contacts for sending SMS.</string>

๐Ÿงช Example

Check the example/ folder for a working demo.


โ— Notes

  • iOS does not allow access to incoming SMS for security/privacy.
  • Android requires runtime permission handling for SMS APIs.
  • On Android 10+, your app needs to be the default SMS app to write to SMS database.

๐Ÿ‘จโ€๐Ÿ’ป Author

Rajkumar07793
Plugin developed with โค๏ธ using Flutter & Kotlin/Swift.


๐Ÿ“„ License

MIT