Interact with Mail though UIDocumentInteractionController
Asked Answered
T

1

8

I'm sharing a PDF to other apps through the UIDocumentInteractionController. Prior to adding this functionality, I had a custom 'send to email' button using the MFMailComposeViewController - yet now there's also a Mail button in my UIDocumentInteractionController, which I'd like to make use of, to avoid having duplicate buttons.

My issue is, through the old mail controller, I used to set a subject, and content text, whereas if I use the UIDocumentInteractionController - I only get a blank email with the PDF attachment. Does anyone know a way I could work round this and get my custom subject and content when using the UIDocumentInteractionController?

I couldn't find anything obvious in the documentation, and clearly I can't meddle with the Mail app to make it communicate with my app - but wondered if anyone else had encountered the problem, and sussed out a 'back-door' solution.

Below is the code for how I'm currently creating and initalising my UIDocumentInteractionController:

-(void)openDocumentIn:(NSString*)filepath
{

    //NSString * filePath = [[NSBundle mainBundle] 
                                  pathForResource:filePath ofType:@"pdf"];
    documentController = [UIDocumentInteractionController 
                         interactionControllerWithURL:[NSURL fileURLWithPath:filepath]];
    documentController.delegate = self;
    documentController.UTI = @"com.adobe.pdf";
    [documentController presentOptionsMenuFromBarButtonItem:
         [self.imageViewController exportQuote] animated:YES];
}
Through answered 30/1, 2014 at 12:53 Comment(2)
Did you ever find the answer?Interleaf
@Interleaf unfortunately not - still an unanswered question!Through
C
0

You can do this through the following code

[self.documentInteractionController setName:@"My Email Subject"];
Conform answered 16/5, 2014 at 4:22 Comment(1)
The question was about setting mail composer's properties. setName: will set instead the UIDocumentInteractionController's title in the navigation bar but not the mail's subject.Simplicity

© 2022 - 2024 — McMap. All rights reserved.