Problem :
I am trying to retrieve the phone number from my Firebase database, but no matter how I enter it into my database it returns an error on my device as follows:
"Message sent to invalid destination. Please check your number and try again. Msg 2127"
The message comes up as an automatic reply immediately after the text is sent out by me. I have tried entering it into firebase as 222-222-2222 and 2222222222 not actually only by using the number 2 but a valid phone number.
My calling function works fine but the same number being texted is not working at all.
var contactph: Int!
@IBAction func textButton(_ sender: Any) {
if canSendText() {
if let contactopt = contacpht{
var messagePH = MFMessageComposeViewController()
messagePH.recipients = ["tel:\(contactopt)"]
messagePH.messageComposeDelegate = self;
self.present(messagePH, animated: false, completion: nil)}}
else {
let errorAlert = UIAlertView(title: "Cannot Send Text Message", message: "Your device is not able to send text messages.", delegate: self, cancelButtonTitle: "OK")
errorAlert.show()
}
}
func canSendTxt() -> Bool {
return MFMessageComposeViewController.canSendTxt()
}
func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
controller.dismiss(animated: true, completion: nil)
}
@IBAction func callButtonPh(_ sender: UIButton) {
if let contactopt = contactph{
if let urlph = NSURL(string: "tel://\(contactopt)") {
// UIApplication.shared.openURL(url as URL)
UIApplication.shared.open(urlph as URL, options: [:], completionHandler: nil)
}
}
}