Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you open the default email app on an iPhone with Flutter?

I want to make a Flutter app and one of the requirements is to open the native email client on the Android or iPhone device. I do NOT wish to create a new email, just open the email app. I would like to be able to open the email client with platform generic code if possible, if not I would like to know what would be required on the iOS side. I am not looking for the Send Email Intent, as I know there is a plugin in Flutter for that. Being a Android Developer I believe I know how to call an Intent from Flutter for that Implicit Intent, if I have to go that way, but I don't have the familiarity with iOS.

like image 688
Peter Birdsall Avatar asked Jun 28 '18 22:06

Peter Birdsall


People also ask

How do I open my default email in Flutter?

Open the default email client app with Flutter. Use the URL Launcher to launch an email within the default email app on your phone.

How do I open my email app?

From the Home screen, tap the Apps icon (in the QuickTap bar) > the Apps tab (if necessary) > Email or tap the Email icon directly from the Home screen. The first time you open the Email app, a setup wizard opens to help you add an email account.

How do I send mail without opening the default email app on Flutter?

Yes, you can directly Send email from your app via SMTP using mailer plugin. You will need to ask and store user's Email, Password, SMTP port, and host and use these credentials to send emails.


2 Answers

The url_launcher plugin does that

mailto:<email address>?subject=<subject>&body=<body>

Create email to in the default email app

See also How do I open a web browser (URL) from my Flutter code?

like image 51
Günter Zöchbauer Avatar answered Oct 19 '22 09:10

Günter Zöchbauer


You need two plugins: android_intent and url_launcher

if (Platform.isAndroid) {
  AndroidIntent intent = AndroidIntent(
    action: 'android.intent.action.MAIN',
    category: 'android.intent.category.APP_EMAIL',
  );
  intent.launch().catchError((e) {
    ;
  });
} else if (Platform.isIOS) {
  launch("message://").catchError((e){
    ;
  });
}
like image 23
BuffK Avatar answered Oct 19 '22 08:10

BuffK