简体   繁体   中英

Why is MFMailComposeViewController crashing on iOS 8.3?

I recently submitted an app for review, which crashed when an email link was brought up. I tried this several times with multiple devices, and was unable to recreate it, but do not have an iPad Air 2. However, it looks as though it may have to do with not having included a check for [MFMailComposeViewController canSendMail] , although I am unsure if that would cause a crash. Can anyone provide some insight into why it crashed? Thanks!

During review, your app crashed on iPad Air 2 running iOS 8.3 when we: 1. Press the Provide Feedback button

Here is the error log:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Last Exception Backtrace:
(0x1839bc2d8 0x1950dc0e4 0x18871ea98 0x188720934 0x1884ea158 0x1000bc128 0x188431404 0x18841a4e0 0x188430da0 0x188430a2c 0x188429f68 0x1883fd18c 0x18869e324 0x1883fb6a0 0x183974240 0x1839734e4 0x183971594 0x18389d2d4 0x18cf8b6fc 0x188462fac 0x1000bc6f0 0x19575aa08)

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x0000000195873270 0x195858000 + 111216
1   libsystem_pthread.dylib         0x000000019591116c 0x19590c000 + 20844
2   libsystem_c.dylib               0x00000001957eab14 0x195788000 + 404244
3   libc++abi.dylib                 0x00000001948a9414 0x1948a8000 + 5140
4   libc++abi.dylib                 0x00000001948c8b88 0x1948a8000 + 134024
5   libobjc.A.dylib                 0x00000001950dc3bc 0x1950d4000 + 33724
6   libc++abi.dylib                 0x00000001948c5bb0 0x1948a8000 + 121776
7   libc++abi.dylib                 0x00000001948c5738 0x1948a8000 + 120632
8   libobjc.A.dylib                 0x00000001950dc290 0x1950d4000 + 33424
9   CoreFoundation                  0x000000018389d380 0x183894000 + 37760
10  GraphicsServices                0x000000018cf8b6f8 0x18cf80000 + 46840
11  UIKit                           0x0000000188462fa8 0x1883ec000 + 487336
12  b2bGatewayWebview               0x00000001000bc6ec 0x100098000 + 149228
13  libdyld.dylib                   0x000000019575aa04 0x195758000 + 10756

The code:

- (IBAction)touchRequestEnhancement:(id)sender {
    // Email Subject
    NSString *emailTitle = @"iOS App Feedback";
    // Email Content
    NSString *messageBody = @"Enter message here";
    // To address
    NSArray *toRecipents = [NSArray arrayWithObject:@"xxxx@xxxx.com"];

    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
    mc.mailComposeDelegate = self;
    [mc setSubject:emailTitle];
    [mc setMessageBody:messageBody isHTML:NO];
    [mc setToRecipients:toRecipents];

    // Present mail view controller on screen
    [self presentViewController:mc animated:YES completion:NULL];
}


- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Mail cancelled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Mail saved");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Mail sent");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Mail sent failure: %@", [error localizedDescription]);
            break;
        default:
            break;
    }

    // Close the Mail Interface
    [self dismissViewControllerAnimated:YES completion:NULL];
}

Writing on iPhone so excuse terseness. Keep a strong reference to the mail controller until the final delegate callback.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM