简体   繁体   中英

Url launcher exception in iOS when subject OR body is in Chinese language

Below code working in android device but in iOS device it's throw an exception

dynamic _sendEmail() async {
    String url = 'mailto:support@test.com?subject=请写以上这个线';
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }
Could not launch mailto:support@k8sllc.com?subject=请写以上这个线

You should encode your url:

String url = Uri.encodeComponent('mailto:support@test.com?subject=请写以上这个线');

so it looks like this:

mailto%3Asupport%40test.com%3Fsubject%3D%E8%AF%B7%E5%86%99%E4%BB%A5%E4%B8%8A%E8%BF%99%E4%B8%AA%E7%BA%BF

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM