I want to open the default e-mail app Inbox screen using flutter. We can use url launcher to open the email compose screen with mailto: url. But that opens the compose screen. What I want is to open the inbox screen. I can't find proper documentation for this.
Asked
Active
Viewed 1.0k times
8
-
Possible duplicate of [How do you open the default email app on an iPhone with Flutter?](https://stackoverflow.com/questions/51091785/how-do-you-open-the-default-email-app-on-an-iphone-with-flutter) – Karan Harsh Wardhan Apr 16 '19 at 05:36
-
@kkarakk That solution did not work for me. – Telvin Mathew Apr 17 '19 at 06:58
-
what happens when you try and use it? – Karan Harsh Wardhan Apr 17 '19 at 11:11
-
@kkarakk It opens the mail compose screen. – Telvin Mathew Apr 18 '19 at 10:53
2 Answers
14
I found the answer using flutter_appavailability library. For those who are searching for the answer please see the steps below.
Add dependency | flutter_appavailability: "^0.0.21" | in pubspec.yaml (Please check the latest version in GitHub)
Add below lines in Xcode Podfile which is required for building the library in iOS
target 'Runner' do
use_frameworks! # required by simple_permission
...
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.0' # required by simple_permission
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
Import below packages
import 'dart:io'; import 'package:flutter_appavailability/flutter_appavailability.dart';
Use below method
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!"))); } }

Josteve
- 11,459
- 1
- 23
- 35

Telvin Mathew
- 345
- 1
- 3
- 10
-
Thank you. I've lost some days already but you stopped the meaningless trying. How can I make this post exposure to google well? – Tiefan Ju Apr 19 '19 at 12:26
-
-
2AppAvailability is an outdated plugin, if you use this it will generate when you releasing the build . So please avoid using this plugin – scienticious Jun 07 '21 at 06:48
-2
Updated answer: Use https://pub.dev/packages/url_launcher and once imported you can create a function
_sendingMails() async {
const url = 'mailto:feedback@geeksforgeeks.org';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
I followed this tutorial here https://www.geeksforgeeks.org/mail-and-sms-in-flutter/

domtom
- 27
- 5
-
2For anyone using iOS simulator, you'll have to use a physical device to test since it doesn't work on the simulator. – domtom Jan 14 '22 at 17:26