Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

_UIViewServiceInterfaceErrorDomain

I'm having a problem with MFMailComposeViewController

I'm getting this error

viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=... {Message=Service Connection Interrupted}

with this code

- (IBAction) mailbutton:(id)sender 
{

    if([MFMailComposeViewController canSendMail]) 
    {

        [MSAPP.globalMailComposer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
        [self presentViewController:MSAPP.globalMailComposer animated:YES completion:nil];

    } 
    else 
    {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                    message:@"Unable to mail. No email on this device?"
                                                   delegate:self
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
        [alert show];
        [MSAPP cycleTheGlobalMailComposer];
    }
}
like image 656
macuser101 Avatar asked Sep 21 '14 16:09

macuser101


1 Answers

This is a known issue with the iOS 8 simulator. Please see this post for a possible workaround.

You MUST allocate and initiate MFMailComposeViewController in an earlier stage, and hold it in one static variable, whenever it's needed, get the static MFMailComposeViewController instance and present it.

AND you will almost certainly have to "cycle" the global MFMailComposeViewController after each use. It is not reliable to "re-use" the same one. Have a global routine which release and then re-initializes the singleton MFMailComposeViewController. Call it each time after you are finished with it

Credit goes to "Joe Blow" for the post. Judging by your code, you have already declared global mail composer. Try "recycling" it as the post suggests to see if that solves your problem. I am having the same issue and unfortunately this solution doesn't fix mine. I can confirm this solution works on the iOS 7.1 simulator but not iOS 8, although it has been suggested it will work on a physical iOS 8 device.

like image 146
rosshump Avatar answered Oct 12 '22 03:10

rosshump