seddik
seddik

Reputation: 646

Send Xamarin.Forms (Android only) SMS without user interaction

I couldn't get sending text messages without user interaction to work, i've scratched the web for it with no luck, am I missing something or it is not possible (yet).

I made it in java (Android Studio) used BroadcastReceiver

Upvotes: 1

Views: 2978

Answers (3)

MNS CHANDRASEKARAN
MNS CHANDRASEKARAN

Reputation: 45

using Plugin.Messaging
var smsMessenger = CrossMessaging.Current.SmsMessenger;
if (smsMessenger.CanSendSmsInBackground)
smsMessenger.SendSmsInBackground("+919999999999", "Test Message");

Upvotes: 1

Sayed M. Idrees
Sayed M. Idrees

Reputation: 1408

I Think you need this. I tested it in Xamarin Android, haven't Testing in Xamarin.Forms.

Manifest Permission

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

C# Code

    using Android.Telephony;

    public void sendSMS(string to,string msg)
    { 
        SmsManager.Default.SendTextMessage(to, null, msg, null, null); 
    }

Upvotes: 0

Pratius Dubey
Pratius Dubey

Reputation: 673

I have used the open source "Xam.Plugins.Messaging" plugin and it work perfect in both platform IOS and android.

And here is code to send sms.

var smsMessenger = MessagingPlugin.SmsMessenger;
if (smsMessenger.CanSendSms)
   smsMessenger.SendSms("+12121212111", "Hello"); 

Upvotes: 0

Related Questions