public override void Finished(MFMailComposeViewController controller, MFMailComposeResult result, NSError error) { switch (result) { case MFMailComposeResult.Failed: MessageBox alert = new MessageBox(); alert.ShowAlert("Email Failed", error.Description, "Ok"); break; default: break; } this.InvokeOnMainThread(delegate { controller.DismissViewController(true, delegate { if (controller != null) { // Dispose of the view object. controller.Dispose(); controller = null; } }); }); }
public void SendMail() { if (MFMailComposeViewController.CanSendMail) { mail = new MFMailComposeViewController(); mail.SetSubject(Subject); mail.SetMessageBody(Body, false); mail.Finished += (sender, e) => { var finished = OnFinished; if (finished != null) finished(this, EventArgs.Empty); mail.Dispose(); mail = null; controller.NavigationController.DismissModalViewControllerAnimated(true); }; controller.NavigationController.PresentModalViewController(mail, true); } }
void SendFeedback() { if (mailController != null) { mailController.Dispose(); mailController = null; } Insights.Track("Tapped Feedback"); if (!MFMailComposeViewController.CanSendMail) { Insights.Track("Feedback failed: No email"); new AlertView(Strings.PleaseSendAnEmailTo, "*****@*****.**").Show(this); return; } mailController = new MFMailComposeViewController(); mailController.SetToRecipients(new[] { "*****@*****.**" }); var tintColor = UIApplication.SharedApplication.KeyWindow.TintColor; mailController.SetSubject(string.Format("Feedback: {0} - {1}", AppDelegate.AppName, versionNumber())); mailController.Finished += async(object s, MFComposeResultEventArgs args) => { if (args.Result == MFMailComposeResult.Sent) { new AlertView(Strings.ThankYou, Strings.YouShouldReceiveAReplyShortly_).Show(this); Insights.Track("Feedback Sent"); } else { Insights.Track("Feedback failed", "Reason", args.Result.ToString()); } await args.Controller.DismissViewControllerAsync(true); if (tintColor != null) { UIApplication.SharedApplication.KeyWindow.TintColor = tintColor; } }; UIApplication.SharedApplication.KeyWindow.TintColor = null; PresentViewController(mailController, true, null); }
public void SendMail() { if (MFMailComposeViewController.CanSendMail) { mail = new MFMailComposeViewController(); mail.SetSubject(Subject); mail.SetMessageBody(Body, false); mail.Finished += (sender, e) => { var finished = OnFinished; if (finished != null) { finished(this, EventArgs.Empty); } mail.Dispose(); mail = null; controller.NavigationController.DismissModalViewControllerAnimated(true); }; controller.NavigationController.PresentModalViewController(mail, true); } }