Xamarin.forms xamarin表单-如何使用预先填充的sms消息打开sms应用程序

Xamarin.forms xamarin表单-如何使用预先填充的sms消息打开sms应用程序,xamarin.forms,Xamarin.forms,我正在使用以下命令打开跨平台的SMS应用程序 OpenUri(新的Uri(String.Format(“sms:{0},”)) 如何预先填充邮件?您可能需要查看可用于此目的的 它揭示了这些方法 public interface ISmsTask { bool CanSendSms { get; } bool CanSendSmsInBackground { get; } void SendSms(string recipient, string message);

我正在使用以下命令打开跨平台的SMS应用程序

OpenUri(新的Uri(String.Format(“sms:{0},”))


如何预先填充邮件?

您可能需要查看可用于此目的的

它揭示了这些方法

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

通过此功能,您可以确定设备是否可以发送短消息,并且您可以使用正文中已有的消息向特定收件人发送短消息


使用URL,您应该能够使用
Device.OpenUri(新的Uri(“sms:+00101010101&body=YourTextHere”)。Android对URI格式要求更严格,请使用
?body=YourTextHere
,这也适用于iOS。

谢谢。它对IOS有效。但是,它对Android不起作用。请尝试将&替换为?最后,谢谢。它起作用了。因此,最终的解决方案是:if(Device.RuntimePlatform==TargetPlatform.iOS.ToString()){Device.OpenUri(新Uri(String.Format(“sms:{0}&body={1}”,“smscocontent”);}或者if(Device.RuntimePlatform==TargetPlatform.Android.ToString()){Device.OpenUri(新Uri(String.Format(“sms:{0}?body={1},”“,smsContent));}您是否也在iOS上尝试过问号版本?它也应该适用于iOS,所以您不需要if。很高兴它成功了!如果它对您有帮助,请接受它作为答案。我会稍微更新它。