使用内置的 URL 方案打开 Mail 应用程序
迅速:
if let url = URL(string: "mailto://azimov@demo.com") {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.openURL(url)
} else {
print("Cannot open URL")
}
}
Objective-C
NSURL *url = [NSURL URLWithString:@"mailto://azimov@demo.com"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
} else {
NSLog(@"Cannot open URL");
}