UIDocumentInteractionController - MailCompose not dismissing in iOS8
Asked Answered
F

1

1

I have a very strange (& serious) problem.

My app uses a UIDocumentInteractionController to share a PDF document. When the user selects the "Mail" option in the controller's pop-up the MailCompose window is opened. But, neither the Send nor Cancel button in this window causes the MailCompose window to be dismissed, meaning the user gets stuck and has to kill the app. The mail does go out though.

Here's the catch: This happens only in iOS8 (both versions released so far) and only on apps installed via the AppStore. That EXACT same version of the app, when running on my device via USB debugging works fine.

Here's some code:

-(void)sharePDF:(id)sender
{
    @try
    {

        NSURL *fileURL = [NSURL fileURLWithPath:currentFileObject.LocalPath];

        if(fileURL)
        {
            //UIDocumentInteractionController

            NSString *newPath;
            @try
            {
                //Create a copy of the file for sharing with a friendly name
                if (currentFileObject.isSpecialReport)
                {
                    newPath = [svc saveReport:[NSData dataWithContentsOfURL:fileURL] ToFile:[NSString stringWithFormat:@"%@.pdf", currentFileObject.ReportName]];
                }
                else
                {
                    newPath = [svc saveReport:[NSData dataWithContentsOfURL:fileURL] ToFile:[NSString stringWithFormat:@"%@.pdf", currentFileObject.PatientFullName]];
                }

            }
            @catch (NSException *exception) {
                return;
            }
            NSURL *newURL = [NSURL fileURLWithPath:newPath];
            self.docController = [UIDocumentInteractionController interactionControllerWithURL:newURL];
            self.docController.delegate = self;
            if (currentFileObject.isSpecialReport)
            {
                self.docController.name = [NSString stringWithFormat:@"Pathology - %@", currentFileObject.ReportName];
            }
            else
            {
                self.docController.name = [NSString stringWithFormat:@"Pathology - %@", currentFileObject.PatientFullName];
            }


            [self.docController presentOptionsMenuFromBarButtonItem:btnShare animated:YES];
        }
    }
    @catch (NSException *exception) {
        return;
    }

}

I do not implement any of the delegate methods since non of them are required, I also do not make use of the preview functionality.

What's most puzzling to me is that the app from the AppStore behaves differently than my local one although the code is identical. My next step is to use the new beta developer tools (Test Flight) to re-publish the app, hoping that I can replicate the problem.

EDIT: I found a similar question on SO here: Cannot dismiss email sheet invoked from UIDocumentInteractionController in iOS 8 After reading that post I think it worth mentioning that I submitted the app to the AppStore via XCode 5 (the last version before XCode 6). Can that really be a factor here? Does Apple not use the same version on their side as the version in which the app was originally built?

Flouncing answered 24/10, 2014 at 9:47 Comment(0)
D
1

I think this is a bug in iOS 8, and if it's still not working for you, I don't think Apple are likely to fix it. I'd upgrade to Xcode 6 and see if that fixes it for you. (It did for us, as you've discovered).

Dreda answered 24/10, 2014 at 10:50 Comment(1)
Thanks. This version of my app was in review for 15 days (almost 16), so now my users have no email functionality for possibly another 15 days? Sigh.Flouncing

© 2022 - 2024 — McMap. All rights reserved.