Launch Mail app (iOS) from my own app
Asked Answered
K

1

3

There's a lot of questions on this topic, but no updated answer. I want to open the native iOS mail app WITHOUT the compose view (from within my own app). All answers so for say it's impossible, but the app Slack manages to do this. Anyone have any idea?

Krystakrystal answered 23/3, 2015 at 9:16 Comment(9)
Where are the other questions? What have you tried?Marilla
google forums, stackoverflow, etc.Krystakrystal
A word of advice: do not blindly trust your users. People may or may not have configured the mail-app you're trying to use.Aloisius
#8822434 "Since the only way to launch other applications is by using their URL schemes, the only way to open mail is by using the mailto: scheme. Which, unfortunately for your case, will always open the compose view."Krystakrystal
@EdwinLambregts regardless, i would like to know how to achieve thisKrystakrystal
How does the link you have supplied in the comment not answer your question? It is basically saying this isn't possible the way to open the Mail App is by using mailto: url scheme which will open it in compose view or you could use the hidden url scheme message: which also opens it in a compose view. There is no way of getting it to open in any other way. It's just not possible.Impatiens
@Impatiens nope, i just realized the urlscheme of message: -> this does not open it in compose viewKrystakrystal
@Krystakrystal are you sure because that link Vladimir has supplied seems to say it will open the composer view with the message you pass in.Impatiens
no i just tried it...it works great.Krystakrystal
B
20

You can launch mail app using message:// url scheme, e.g.

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

I was not able to find any information about it in apple documentation, but the scheme is present in URL schemes section (not private urls!) in mail's Info.plist, so I assume it is a part of a public api. You can also find some information on the topic here

Brandy answered 23/3, 2015 at 13:35 Comment(4)
awesome! I was trying to guess what the urlscheme was but mail:// was n't working for meKrystakrystal
That if statement doesn't read correctly. Is that correct? Shouldn't it be if ([[UIApplication SharedApplication] canOpenURL:mailURL])????Impatiens
@Popeye, you're right - that was copypaste error )Brandy
Great to find this! Do you know if we can use that URL scheme so that Mail app opens an e-mail file (.msg from Outlook or similar) giving a URL where the file is hosted? So something like message://http://domain/file.msg.Legato

© 2022 - 2024 — McMap. All rights reserved.