Recently I upgraded to Xcode 7.0.1 and running on iOS 9 Simulator,I started facing error 'MailcompositionService quit unexpectedly'
My Email Button Click's code:
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
composer.mailComposeDelegate = self;
[composer setToRecipients:[NSArray arrayWithObjects:@"example@example.com", nil]];
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* version = [infoDict objectForKey:@"CFBundleShortVersionString"];
NSString *ver = [[UIDevice currentDevice] systemVersion];
[composer setMessageBody:[NSString stringWithFormat:@"\n\n\n\n\n\n App Version %@ \n iOS Version %@", version, ver] isHTML:NO];
int count = 1;
for (NSString *fullPath in [DeviceLoger getLogFilesPath])
{
NSData *fileData = [NSData dataWithContentsOfFile:fullPath];
[composer addAttachmentData:fileData mimeType:@"text/plain" fileName:[NSString stringWithFormat:@"Log_File_%d",count]];
count++;
}
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
composer.modalPresentationStyle = UIModalPresentationFormSheet;
[ROOT_VIEW_CONTROLLER presentViewController:composer animated:YES completion:NULL];
}
else
[self presentViewController:composer animated:YES completion:nil];
}
else
[Utility showDialog_OK:nil withMessage:NO_EMAIL_SETUP andButton:@"OK"];
Also Delegate Method gives error as nil:
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
if(error)
{
[Utility showAlertWithTitle:@"" message:@"Error sending messaage. Please try again." delegate:nil tag:0 buttons:@[@"Ok"]];
}
else
{
[controller dismissViewControllerAnimated:YES completion:^{
[controller release];
}];
} }
Any Ideas ?