Search code examples
iosobjective-cipadmfmailcomposeviewcontroller

MFMailComposeViewController crash on iPad


I am using the below code for both iPhone & iPad.

if([MFMailComposeViewController canSendMail])
{
     dispatch_async(dispatch_get_main_queue(), ^{

         MFMailComposeViewController *mailcomposer=[[MFMailComposeViewController alloc] init];
         [mailcomposer setMailComposeDelegate:self];
         [mailcomposer setToRecipients:[NSArray arrayWithObject:recipients]];
         [self presentViewController:mailcomposer animated:YES completion:nil];
      });
}

It's work fine in iPhone but in case of iPad the modal has open and after few seconds it's automatically got dismissed. After putting it into debug mode I found below log.

viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x7fbb904040f0 {Message=Service Connection Interrupted}
<MFMailComposeRemoteViewController: 0x7fbb928b3250> timed out waiting for fence barrier from com.apple.MailCompositionService

Solution

  • You can run the MFMailComposeViewController on a real physical Device/iPad, but it might give issues on the simulator.