0
votes

I am using QLPreviewController for showing the pdf. And I am sending pdf by tapping the share button and then tap on email in the QLPreviewController.

But i don't know how to get that share button method in QLPreviewController to validate that the email account is available or not. Here is the screenshot:

enter image description here Please let me know about this.

Thanks in advance.

2
Do you want to check if a email account is valid or not? - Rashad
@Rashad....Yes i just want to check that email account is setup in the device or not.... - Sarabjit Singh
What do you mean by setup in the device? That email is store in the device or the device is using the email? - Rashad
I mean that when i tap on send email button and if there is no email account setup(Store)in the device there should be an alert message... - Sarabjit Singh
See the MFMailComposeViewController canSendMail: method. - rmaddy

2 Answers

0
votes

if you have UInavigationController then you can add a bar button for sharing the content. Or you can add a share button in your viewcontroler.

Use MessageUI. Add the delegates MFMessageComposeViewControllerDelegate, MFMailComposeViewControllerDelegate.

- (IBAction)contactBtn:(id)sender {
    if ([MFMailComposeViewController canSendMail]){
        MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
        [controller setSubject:@"Subject"];
        [controller setMessageBody:@" " isHTML:NO];
        [controller setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]];
        controller.mailComposeDelegate = self;
        [self presentViewController:controller animated:YES completion:NULL];
    }
    else{
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Failed!" message:@"Mail can not be sent. Check your email settings." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil] ;
        [alert show];
    }
}

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    [self dismissViewControllerAnimated:YES completion:NULL];
}
0
votes

The QL previewer is working on separate process. Something like a different app. So there is no way to customize the share button. see details here

This may help you. See this answer.