Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 362 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you open the default email app on an iPhone with Flutter?

#1
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.
Reply

#2
The [url_launcher](

[To see links please register here]

) plugin does that

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

<!-- -->

> Create email to <email address> in the default email app

See also

[To see links please register here]

Reply

#3
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){
;
});
}
Reply

#4
You can use [email_launcher][1]

Example

```dart
Email email = Email(
to: ['[email protected],[email protected]'],
cc: ['[email protected]'],
bcc: ['[email protected]'],
subject: 'subject',
body: 'body'
);
await EmailLauncher.launch(email);
```


[1]:

[To see links please register here]

Reply

#5
This library solved it perfectly for me:

[To see links please register here]

. The example is good and the api is simple and obvious.
Reply

#6
this answer may be the solution [

[To see links please register here]

][1]

```
void openEmailApp(BuildContext context){
try{
AppAvailability.launchApp(Platform.isIOS ? "message://" : "com.google.android.gm").then((_) {
print("App Email launched!");
}).catchError((err) {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("App Email not found!")
));
print(err);
});
} catch(e) {
Scaffold.of(context).showSnackBar(SnackBar(content: Text("Email App not found!")));
}
}
```

[1]:

[To see links please register here]

Reply

#7
use url_launcher plugin [url_launcher][1]


[1]:

[To see links please register here]


Future<void> _launched;

Future<void> _openUrl(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}

Then for Phone

setState(() {
_launched = _openUrl('tel:${+917600896744}');
});

for email

setState(() {
_launched = _openUrl('mailto:${[email protected]}'');
});


**Update July 2021**

Add Following Lines in Manifest File

<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>



Reply

#8
launch("mailto:<email address>?subject=<subject>&body=<body>");

use [url_launcher][1] package


[1]:

[To see links please register here]

Reply

#9
I'm using `open_mail_app: ^0.4.5` for this, it works pretty well and it took 2 min to add it to my app:

// Android: Will open mail app or show native picker.
// iOS: Will open mail app if single mail app found.
var result = await OpenMailApp.openMailApp();

It shows all 3 of my email apps that I have installed on my android smartphone, but for some reason it also gives the option to open my paypal app, which could make users of my app think to be a bit sus.

The developer of open_mail_app has added a filter to filter out paypal, but it seems not to work:

/// Default filter list includes PayPal, since it implements the mailto: intent-filter
/// on Android, but the intention of this plugin is to provide
/// a utility for finding and opening apps dedicated to sending/receiving email.
Reply

#10
U can use [url_luncher][1]:


await launchUrl(Uri.parse("mailto:email?subject=subject&body=body"))


[1]:

[To see links please register here]


& don't use launch as it's deprecated:

launch("mailto:<email address>?subject=<subject>&body=<body>");
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through