var result = await BackgroundSms.sendMessage(
phoneNumber: "9xxxxxxxxx", message: "hello");
if (result == SmsStatus.sent) {
print("Sent");
} else {
print("Failed");
}
I added the permission in the android manifest still not working
W/System.err(10301): java.lang.SecurityException: Sending SMS message: uid 10909 does not have android.permission.SEND_SMS.
W/System.err(10301): at android.os.Parcel.createException(Parcel.java:2071)
W/System.err(10301): at android.os.Parcel.readException(Parcel.java:2039)
W/System.err(10301): at android.os.Parcel.readException(Parcel.java:1987)
W/System.err(10301): at com.android.internal.telephony.ISms$Stub$Proxy.sendTextForSubscriber(ISms.java:1684)
W/System.err(10301): at android.telephony.SmsManager$1.onSuccess(SmsManager.java:394)
W/System.err(10301): at android.telephony.SmsManager.sendResolverResult(SmsManager.java:1408)
W/System.err(10301): at android.telephony.SmsManager.resolveSubscriptionForOperation(SmsManager.java:1376)
W/System.err(10301): at android.telephony.SmsManager.sendTextMessageInternal(SmsManager.java:389)
W/System.err(10301): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:362)
W/System.err(10301): at com.j.background_sms.BackgroundSmsPlugin.sendSMS(BackgroundSmsPlugin.java:82)
W/System.err(10301): at com.j.background_sms.BackgroundSmsPlugin.onMethodCall(BackgroundSmsPlugin.java:54)
W/System.err(10301): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
W/System.err(10301): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
W/System.err(10301): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
W/System.err(10301): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(10301): at android.os.MessageQueue.next(MessageQueue.java:336)
W/System.err(10301): at android.os.Looper.loop(Looper.java:197)
W/System.err(10301): at android.app.ActivityThread.main(ActivityThread.java:7500)
W/System.err(10301): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(10301): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
W/System.err(10301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
I/flutter (10301): PlatformException(Failed, Sms Not Sent, , null)
var result = await BackgroundSms.sendMessage( phoneNumber: "9xxxxxxxxx", message: "hello"); if (result == SmsStatus.sent) { print("Sent"); } else { print("Failed"); }
I added the permission in the android manifest still not working
W/System.err(10301): java.lang.SecurityException: Sending SMS message: uid 10909 does not have android.permission.SEND_SMS. W/System.err(10301): at android.os.Parcel.createException(Parcel.java:2071) W/System.err(10301): at android.os.Parcel.readException(Parcel.java:2039) W/System.err(10301): at android.os.Parcel.readException(Parcel.java:1987) W/System.err(10301): at com.android.internal.telephony.ISms$Stub$Proxy.sendTextForSubscriber(ISms.java:1684) W/System.err(10301): at android.telephony.SmsManager$1.onSuccess(SmsManager.java:394) W/System.err(10301): at android.telephony.SmsManager.sendResolverResult(SmsManager.java:1408) W/System.err(10301): at android.telephony.SmsManager.resolveSubscriptionForOperation(SmsManager.java:1376) W/System.err(10301): at android.telephony.SmsManager.sendTextMessageInternal(SmsManager.java:389) W/System.err(10301): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:362) W/System.err(10301): at com.j.background_sms.BackgroundSmsPlugin.sendSMS(BackgroundSmsPlugin.java:82) W/System.err(10301): at com.j.background_sms.BackgroundSmsPlugin.onMethodCall(BackgroundSmsPlugin.java:54) W/System.err(10301): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) W/System.err(10301): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) W/System.err(10301): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818) W/System.err(10301): at android.os.MessageQueue.nativePollOnce(Native Method) W/System.err(10301): at android.os.MessageQueue.next(MessageQueue.java:336) W/System.err(10301): at android.os.Looper.loop(Looper.java:197) W/System.err(10301): at android.app.ActivityThread.main(ActivityThread.java:7500) W/System.err(10301): at java.lang.reflect.Method.invoke(Native Method) W/System.err(10301): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) W/System.err(10301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935) I/flutter (10301): PlatformException(Failed, Sms Not Sent, , null)