soil_logr icon indicating copy to clipboard operation
soil_logr copied to clipboard

Check if iOS has access to a mailing app

Open KipCrossing opened this issue 4 years ago • 1 comments
trafficstars


final bool canSend = await FlutterMailer.canSendMail();

  if(!canSend && Platform.isIOS) {
    final url = 'mailto:?body=$body&subject=$subject';
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      print("FlutterMailer");
      createAlertDialog(BuildContext context) {
        return showDialog(context: context, builder: (context) {
          return AlertDialog(
            title: Text('Delete all samples'),
            content: Text('Are you sure you want to delete?'),
            actions: [
              MaterialButton(
                child: Text('Ok'),
                onPressed: () {
                  // Navigator.of(context).pop(SampleList());
                },
              ),

            ],
          );
        });
      }
      throw 'Could not launch $url';
    }
  }

KipCrossing avatar Feb 09 '21 04:02 KipCrossing

Something like this but this is not perfect. May need to pass the context to the mailer functions of pass back a response.

KipCrossing avatar Feb 09 '21 04:02 KipCrossing