CShark
CShark

Reputation: 33

xamarin forms - how to open sms application with prefilled sms message

I am using the following to open the SMS application cross platform

Device.OpenUri(new Uri(String.Format("sms:{0}", "")));

How can I prefill the message?

Upvotes: 1

Views: 1379

Answers (1)

Gerald Versluis
Gerald Versluis

Reputation: 34128

You probably want to look at the Messaging plugin that is available for this.

It exposes these methods;

public interface ISmsTask
{
    bool CanSendSms { get; }
    bool CanSendSmsInBackground { get; }
    void SendSms(string recipient, string message);
    void SendSmsInBackground(string recipient, string message);
}

For more detail read here.

With this you can determine if the device can send a SMS and you can compose one to a certain recipient with a message already in the body.

Using an URL you should be able to do so with Device.OpenUri(new Uri("sms:+00101010101&body=YourTextHere"));. Android is more strict on the URI format, use ?body=YourTextHere, this should work for iOS as well.

Upvotes: 2

Related Questions