Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 14 - How to open Default Mail App programmatically?

With iOS14 users can set different email client apps as their default.

Is there a way to open the selected default mail app programmatically?

Using mailto: URLs, after setting the default mail app to Gmail, don't do anything.

like image 518
Peter Lendvay Avatar asked Oct 20 '20 14:10

Peter Lendvay


People also ask

How do I change my default email app in iOS 14?

Go to Settings and scroll down until you find the browser app or the email app. Tap the app, then tap Default Browser App or Default Mail App. Select a web browser or email app to set it as the default. A checkmark appears to confirm it's the default.

How do I open an email in iOS Swift?

Show activity on this post. let email = "[email protected]" let url = URL(string: "mailto:\(email)") UIApplication. shared. openURL(url!)


Video Answer


2 Answers

Apparently you have to add mailto to the LSApplicationQueriesSchemes to make it work.

like image 149
Peter Lendvay Avatar answered Oct 16 '22 09:10

Peter Lendvay


Add following to info.plist

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>https</string>
    <string>http</string>
    <string>mailto</string>
</array>
like image 1
Safdar Ali Avatar answered Oct 16 '22 11:10

Safdar Ali