SmsFlutter is a Flutter plugin for sending and receiving SMS messages, checking SIM count, and managing SMS permissions on Android devices. It allows you to send SMS messages through a specific SIM slot (for dual-SIM devices), receive incoming SMS messages, and request necessary permissions from the user.
- Send SMS using a selected SIM card
- Receive SMS messages
- Get the number of active SIM cards
- Check SMS permissions
- Request SMS permissions
| Platform | Support |
|---|---|
| Android | ✔️ |
| iOS | ❌ |
Add the dependency to your pubspec.yaml:
dependencies:
sms_flutter:
path: ./path_to_your_pluginImport the plugin:
import'package:sms_flutter/sms_flutter.dart';
final sms =SmsFlutter();voidmain() async {
final sms =SmsFlutter();
// Check permissionsbool hasPermission =await sms.checkPermissions();
if (!hasPermission) {
await sms.requestPermissions();
}
// Get SIM countint simCount =await sms.getSimCount();
print("SIM Count: $simCount");
// Send SMSString result =await sms.sendSmsWithSim(
phoneNumber:'+1234567890',
message:'Hello from Flutter!',
simSlot:0,
);
print("SMS Send Result: $result");
// Receive SMSMap<String, String> received =await sms.receiveSms();
print("Received SMS: $received");
}| Function Name | Parameters | Return Type | Description |
|---|---|---|---|
getSimCount() | None | Future<int> | Returns the number of SIM cards available on the device. |
sendSmsWithSim() | phoneNumber: Stringmessage: StringsimSlot: int (default: 0) | Future<String> | Sends an SMS via the specified SIM slot. |
receiveSms() | None | Future<Map<String,String>> | Receives the most recent SMS message (implementation may vary). |
checkPermissions() | None | Future<bool> | Checks if SMS permissions are granted. |
requestPermissions() | None | Future<void> | Requests SMS permissions from the user. |
Ensure the following permissions are declared in your Android AndroidManifest.xml:
<uses-permissionandroid:name="android.permission.SEND_SMS"/>
<uses-permissionandroid:name="android.permission.RECEIVE_SMS"/>
<uses-permissionandroid:name="android.permission.READ_SMS"/>
<uses-permissionandroid:name="android.permission.READ_PHONE_STATE"/>If you have any issues or suggestions, feel free to reach out to me:
- 📢 Telegram: @mgh_zdev
- 💻 GitHub: mgh-devs
- 🔗 LinkedIn: Ghanizadeh Mohammad