我正在开发Xamarin.Forms项目,iOS,安卓和Windows Phone。
我的应用程序要求用户输入短信和电话号码,然后在提交时,我需要发送短信到电话号码。
我更喜欢为所有平台提供一个单一的实现。
发布于 2017-02-14 23:15:06
您可以使用这个开源插件Xam.Plugins.Messaging https://github.com/cjlotz/Xamarin.Plugins
这是提供的示例(来自https://github.com/cjlotz/Xamarin.Plugins/blob/master/Messaging/Details.md ):
// Make Phone Call
var phoneDialer = CrossMessaging.Current.PhoneDialer;
if (phoneDialer.CanMakePhoneCall)
phoneDialer.MakePhoneCall("+272193343499");
// Send Sms
var smsMessenger = CrossMessaging.Current.SmsMessenger;
if (smsMessenger.CanSendSms)
smsMessenger.SendSms("+27213894839493", "Well hello there from Xam.Messaging.Plugin");
var emailMessenger = CrossMessaging.Current.EmailMessenger;
if (emailMessenger.CanSendEmail)
{
// Send simple e-mail to single receiver without attachments, bcc, cc etc.
emailMessenger.SendEmail("to.plugins@xamarin.com", "Xamarin Messaging Plugin", "Well hello there from Xam.Messaging.Plugin");
// Alternatively use EmailBuilder fluent interface to construct more complex e-mail with multiple recipients, bcc, attachments etc.
var email = new EmailMessageBuilder()
.To("to.plugins@xamarin.com")
.Cc("cc.plugins@xamarin.com")
.Bcc(new[] { "bcc1.plugins@xamarin.com", "bcc2.plugins@xamarin.com" })
.Subject("Xamarin Messaging Plugin")
.Body("Well hello there from Xam.Messaging.Plugin")
.Build();
emailMessenger.SendEmail(email);
}
发布于 2018-08-21 05:20:26
微软现在在他们新的包罗万象的https://docs.microsoft.com/en-us/xamarin/essentials NuGet包中提供了这一功能。
https://stackoverflow.com/questions/42229530
复制相似问题