Following the documentation from Apple, I was able to successfully pop the MFMailComposeViewController modal up with prefilled email recipients. Well, until I tried to prefil the modal with an internationalized email address with non-ascii characters:
let picker = MFMailComposeViewController()
picker.setToRecipients(["eai-testé@domain.tld"])
// ...
Surprisingly, when I input the non-ascii email manually, there is no problem with the mail native app. I successfully find a programmatical ugly workaround:
var email = "eai-testé@domain.tld".addingPercentEncoding(withAllowedCharacters: .alphanumerics)
var str = "mailto:" + email.unsafelyUnwrapped
UIApplication.shared.openURL(URL(string: str).unsafelyUnwrapped)
This method won't work with the MFMailComposeViewController since it uses url encoding, which does not make sense for a plain email address. Of course, not using MFMailComposeViewController isn't good, since the workaround doesn't have a predicate to intercept errors and stuff like that.
MFMailComposeViewController
, too. Now, whether our mail servers support it or not is a separate question...