0
我只是新的Swift語言和編碼。我創建了一個功能,可以撥打手機號碼並創建了一個可以發送短信的功能。調用函數完成後,sendJSON將執行。 有人可以幫助我。由於函數調用後執行
呼叫功能
func call() {
if let telephoneURL = URL(string: "tel://\(dispatchNumber.replacingOccurrences(of: " ", with: ""))") { //Calling on the phone
if #available(iOS 10.0, *) {
UIApplication.shared.open(telephoneURL, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(telephoneURL)
}
}
}
SendSMS功能
func sendJSON() {
let messageVC = MFMessageComposeViewController()
if(MFMessageComposeViewController.canSendText())
{
messageVC.messageComposeDelegate = self
messageVC.body = "test"
messageVC.recipients = "123456789"
UIApplication.shared.keyWindow?.rootViewController?.present(messageVC, animated: true, completion: nil)
}
}