我已经看到很多提到使用MessageUI Framework来组合消息的东西,但有没有办法在Swift中自动发送它?也许甚至允许我的代码在按下发送按钮后运行,然后我调用实际方法发送它。
答案 0 :(得分:1)
您无法在未经用户确认的情况下发送消息,但您可以随时提供MFMessageComposeViewController
。
import MessageUI
func sendSMS(with text: String) {
if MFMessageComposeViewController.canSendText() {
let messageComposeViewController = MFMessageComposeViewController()
messageComposeViewController.body = text
present(messageComposeViewController, animated: true, completion: nil)
}
}