• Register
0 votes
70 views

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)

}

}

}

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I solved the issue by changing messagePH.recipients = ["tel:(contactopt)"]

To below code:

messagePH.recipients = [String(contactopt)]

9 7 4
38,600 points

Related questions

0 votes
1 answer 3 views
3 views
Problem: I installed the "Contact Form 7" plugin in WordPress and created a form. When i click on the submit button, the following error appears: There was an error trying to send your message. Please try again later.
asked Mar 19 ummesalma 25.2k points
0 votes
1 answer 2 views
2 views
Problem: I need assistance in resolving this problem in error a jni error has occurred please check your installation and try again.
asked Apr 6 tuhin1 48.9k points
0 votes
1 answer 2 views
2 views
Problem: I need help in resolving this problem in The online content is unavailable please, check your internet connection and try again?
asked Apr 6 tuhin1 48.9k points
0 votes
1 answer 3 views
3 views
Problem: How do I fix this problem? the online content is unavailable please, check your internet connection and try again
asked Apr 1 rakib1 51.5k points
0 votes
1 answer 14 views
14 views
Problem: please check your network connection and try again android.
asked Feb 19 Dan phillip 4.8k points
0 votes
1 answer 633 views
633 views
Problem : My code works perfectly on my friend's laptop But throws below error on my laptop. “Error: a jni error has occurred, please check your installation and try again” I have tried running the code on a Eclipse Juno using Java 7. I have also tested it and ... my final year project and I need it to work on my laptop at any case, I will be very grateful to anyone who solves it.
asked Jan 18, 2020 jwilliam 3.9k points
1 vote
1 answer 2 views
2 views
Problem: I need a help , How I can fix this : the link you have used to enter the paypal system is invalid. please review the link and try again.
asked 3 days ago MUHAMMAD MUNEEB 83k points
0 votes
1 answer 4 views
4 views
Problem: I am trying to upload an Apple TV App to the App Store for testing purposes, but I got the issue: This Action could not be completed. Try Again (-22421)
asked Mar 19 ummesalma 25.2k points
0 votes
0 answers 24 views
24 views
Problem: How to fix this error:your session has expired. please refresh the page and try again.
asked Mar 3 amir.zaib45 1.2k points
0 votes
1 answer 4 views
4 views
Problem: Do you have any suggestions about how I can resolve this “Gradle project sync failed. please fix your project and try again”?
asked Apr 5 tuhin1 48.9k points