We would like to give the ability to the user to choose any installed email client (Gmail, Yandex, etc.) in our app. But iOS provides only Mail or builtin MFMailComposeViewController. Is there any way to present a list of email clients to the user?
Asked
Active
Viewed 3,414 times
6
Dávid Pásztor
- 51,403
- 9
- 85
- 116
demensdeum
- 155
- 3
- 10
-
Possible duplicate of [How can I launch an email client on ios using Swfit](https://stackoverflow.com/questions/26052815/how-can-i-launch-an-email-client-on-ios-using-swfit) – Maxime Jul 31 '17 at 12:43
-
1iMail? iMail View Controller? – El Tomato Jul 31 '17 at 12:44
-
I mean Mail or MFMailComposeViewController – demensdeum Jul 31 '17 at 12:47
3 Answers
9
There's no way to achieve this directly, as iOS doesn't know the concept of 'default application'. You could implement yourself a function which checks the various URLs used by different iOS email clients, and determines which clients are installed. For instance, GMail uses googlegmail://. You could also show a menu with the clients found on the device.
If you don't want to create your own implementation, ThirdPartyMailer is a library that can do this for you.
Andrea Gottardo
- 1,329
- 11
- 23
-
In this ThirdPartyMailer how to attach the zip file in the mail compose? – saravanar May 01 '19 at 12:14
-
2Since iOS14 users can now set a default email app, which will be used when you use mailto:// in your app – Peter Johnson Oct 14 '20 at 10:55
1
If you're looking for something similar to the way Android handles it, then no it's not possible. Some email apps though might support a custom scheme - for example Gmail uses googlegmail:// (taken from this question).
phi
- 10,634
- 6
- 53
- 88
-3
You should try something like this:
let url = NSURL(string: "mailto:jon.doe@mail.com")
UIApplication.sharedApplication().openURL(url)
Maxime
- 1,332
- 1
- 15
- 43
-
-
So you have to create your own Picker with list of available mail clients. To build this list you can check for each scheme if `canOpenUrl:` it will tell you if user has installed the application or not – Maxime Jul 31 '17 at 12:54
-
I am wondering if there is way to present all apps, that can handle "mailto" links. – demensdeum Jul 31 '17 at 12:55
-
1