Josh Eldridge
05/26/2023, 5:59 PMMFMailComposeViewController
but am unsure how to present it to the user. I've been experimenting and tried:
val rootViewController = UIApplication.sharedApplication().delegate?.window?.rootViewController()
rootViewController?.presentViewController(mfMailComposeViewController, animated = true, null)
But it fails when grabbing the window. I'm not super familiar with iOS concepts so I'm sure there is some fundamental knowledge missing here.Josh Eldridge
05/26/2023, 6:14 PMmailto:
URL and have the application open the URL without messing with viewsRene Gens
10/18/2024, 2:29 PMmailto
is the way to go. Here in a full code snippet.
actual fun sendEmail(onError: () -> Unit) {
val mailtoString = "mailto:${iosSupportEmail}?subject=Support for Papely ${getBuildVersion()}"
val mailtoUrl = NSURL(string = mailtoString)
if (UIApplication.sharedApplication.canOpenURL(mailtoUrl)) {
UIApplication.sharedApplication.openURL(mailtoUrl)
} else {
onError.invoke()
}
}