Xamarin - iOS MFMailComposeViewController.CanSendMail 导致“在执行本机代码时得到 segv”

时间:2021-02-16 21:04:25

标签: xamarin xamarin.forms xamarin.ios

我正在尝试使用带有 DependencyInjection 的 iOS 代码从 Xamarin Forms 应用程序发送电子邮件,如下所示:

[assembly: Xamarin.Forms.Dependency(typeof(SendMail))]
namespace SampleApp.iOS.PlatformSpecific
{
  public class SendMail : ISendMail
  {
    public void SendMail()
    {
       Device.BeginInvokeOnMainThread(() =>
       {
         if (MFMailComposeViewController.CanSendMail)  <-- crashes here
         {
            // my code
         }
       }
     }
  }
}

上面指示的行在真实设备上总是崩溃(但在模拟器上有效)。崩溃如下:

=================================================================
    Native Crash Reporting
=================================================================
Got a segv while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

有什么想法可能出问题了吗?

0 个答案:

没有答案
相关问题