【发布时间】:2016-12-09 14:58:20
【问题描述】:
在我的应用程序中,出于调试目的和测试目的,我需要发送一封电子邮件。
当发送邮件控制器的类不包含 PresentViewController 的定义时,我如何呈现邮件控制器?在用户从触发的警报中单击“是”后,该类需要触发电子邮件应用程序。
public async Task<bool> SendEmail(Exception ex)
{
var result = await SendNotificationToRequestSendingEmail();
if (result)
{
if (MFMailComposeViewController.CanSendMail)
{
mailController = new MFMailComposeViewController();
mailController.SetToRecipients(new string[] { "test@one.com", "test@two.com" });
mailController.SetSubject("Details");
mailController.SetMessageBody($"Message: {ex.Message}" +
$"Exception: {ex.ToString()}"
, false);
mailController.Finished += (object s, MFComposeResultEventArgs args) =>
{
Console.WriteLine(args.Result.ToString());
args.Controller.DismissViewController(true, null);
};
this.PresentViewController(mailController, true, null); //this line causes the error
}
}
return true;
}
我该如何解决或解决此问题?这是从 Xamarin 表单页面调用的。
【问题讨论】:
标签: c# email xamarin.ios xamarin.forms presentviewcontroller