Reputation: 51
How to delete an SMS from the inbox in Android programmatically using flutter? anyone can help? Thanks for your helping
Upvotes: 5
Views: 3764
Reputation: 3509
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).
Upvotes: 2
Reputation: 5973
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.
Upvotes: 1
Reputation: 5973
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 .
Upvotes: 3