如何用swift发送邮件和短信?

时间:2017-03-15 19:43:58

标签: ios swift email sms

我用swift 3添加了调用函数:

@IBAction func call_click(_ sender: UIButton) {

    let url:NSURL = NSURL(string: "telprompt://" + phone_number!)!
    UIApplication.shared.openURL(url as URL)
}

此代码正常调用并返回应用程序。我也想添加邮件和短信。 我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

对于SMS,请使用此URL架构:

sms:1-408-555-1212

如此处所述:https://developer.apple.com/library/content/featuredarticles/iPhoneURLScheme_Reference/SMSLinks/SMSLinks.html

对于电子邮件使用mailto:

mailto:foo@example.com?cc=bar@example.com&subject=Greetings%20from%20Cupertino!&body=Wish%20you%20were%20here!

如此处所述:https://developer.apple.com/library/content/featuredarticles/iPhoneURLScheme_Reference/MailLinks/MailLinks.html

希望这会有所帮助。