How to delete an SMS from the inbox in Android programmatically using flutter? anyone can help? Thanks for your helping
How to delete an SMS from the inbox in Android programmatically using flutter? anyone can help? Thanks for your helping
yes there is library available for this
Sending SMS
import 'package:sms/sms.dart';
void main() {
SmsSender sender = new SmsSender();
String address = someAddress();
...
sender.sendSms(new SmsMessage(address, 'Hello flutter!'));
}
Receiving SMS
import 'package:sms/sms.dart';
void main() {
SmsReceiver receiver = new SmsReceiver();
receiver.onSmsReceived.listen((SmsMessage msg) => print(msg.body));
}
Deleting SMS
SmsRemover smsRemover = SmsRemover();
<boolean value> = await smsRemover.removeSmsById(sms.id, _smsThread.threadId)
for more deteial checkout this page. sms_maintained .
this answer as your comment (for listening incoming SMS ).
Getting all SMS messages #
import 'package:sms/sms.dart';
void main() {
SmsQuery query = new SmsQuery();
List<SmsMessage> messages = await query.getAllSms;
}
This list (messages) return all sms.
The above 'package:sms/sms.dart' is no longer up to date.
You can use the telephony package instead.
For example, sending an SMS:
Import the telephony package:
import 'package:telephony/telephony.dart';
Retrieve the singleton instance of telephony by calling:
final Telephony telephony = Telephony.instance;
Add the following permission in your AndroidManifest.xml:
<uses-permission android:name="android.permission.SEND_SMS"/>
And then, to send the SMS directly from your app:
telephony.sendSms(
to: "1234567890",
message: "May the force be with you!"
);
In the above documentation, they tell you how to also read SMS messages and more (didn't see how to delete though).