2

I have a button that when it is clicked, It will let us choose between default mail app, yahoo mail and Safari to read inbox. Currently i'm using:

NSURL* mailURL = [NSURL URLWithString:@"mailto:abc@gmail.com&subject=My%20Subject%20Line&body=Hello%20Email!"];
[[UIApplication sharedApplication] openURL: mailURL];

This code always open the compose screen. I don't want it be shown. I just want to open inbox or just only open the mail app. How can I implement that? Thank you very much!

UPDATE

I know how to open app without compose screen now.

If you want to open default mail app, use:

NSURL* mailURL = [NSURL URLWithString:@"message://"];

If you want to open Gmail, use:

NSString *gmailUrl = @"googlegmail://";

Now the problem is: How to show a dialog to choose between them

Like this picture

DurianPham
  • 23
  • 6

1 Answers1

0

May be below code can help:

NSURL* mailURL = [NSURL URLWithString:@"message://"];
if ([[UIApplication sharedApplication] canOpenURL:mailURL]) {
    [[UIApplication sharedApplication] openURL:mailURL];
}

Reads more at: https://www.macstories.net/tutorials/ios-7-and-mail-message-urls/

Also check Vladimir's answer: https://stackoverflow.com/a/29211632/5575752

Community
  • 1
  • 1
Ronak Chaniyara
  • 5,335
  • 3
  • 24
  • 51