简体   繁体   中英

How to make the email open in the app when in mobile

I wanted to make a button integrated in my email, so that when the user clicks on it from the browser from desktop, the button open in the browser itself.

And if the user is viewing it from mobile, should open up in the application.

How can I do that?

You can try this one: Do not forget to declare its delegate.

if ([MFMailComposeViewController canSendMail]) {
        MFMailComposeViewController * emailController = [[MFMailComposeViewController alloc] init];
        emailController.mailComposeDelegate = self;

        [emailController setSubject:subject];
        [emailController setMessageBody:mailBody isHTML:YES];   
        [emailController setToRecipients:recipients];

        [self presentViewController:emailController animated:YES completion:nil];

        [emailController release];
    }
    // Show error if no mail account is active
    else {
        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"You must have a mail account in order to send an email" delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"OK") otherButtonTitles:nil];
        [alertView show];
        [alertView release];
    }

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