how to auto send a message skipping the iMessage interface

the question is:

how can i skip the IMessage interface in the iPhone and auto send the data entered by the user in UITEXTFIELDS ?


the user must enter the "MESSAGE" into UITEXTFIELD

controller.body = message.text


and the phone number aswell


controller.recipients = [String(number.text!)]


them when the button is clicked by the user to send the message

@IBAction funcsendnotification(_ sender: UIButton) {
        if (MFMessageComposeViewController.canSendText()){
            let controller = MFMessageComposeViewController()
           
            controller.body = message.text
            controller.recipients = [String(number.text!)]
            controller.messageComposeDelegate = self
            self.present(controller, animated: true, completion: nil)
        }
    }


the New IMessage 'iphone interface jumps' and i dont want it to show that, i want to skip it and just send the message by enter the UITEXTFIELD for both automatically






all code so far

import UIKit
import MessageUI


class ViewController: UIViewController, MFMessageComposeViewControllerDelegate {
   
   



    @IBOutlet weak var number: UITextField!
    @IBOutlet weak var message: UITextField!
    @IBAction func sendnotification(_ sender: UIButton) {
        if (MFMessageComposeViewController.canSendText()){
            let controller = MFMessageComposeViewController()
           
            controller.body = message.text
            controller.recipients = [String(number.text!)]
            controller.messageComposeDelegate = self
            self.present(controller, animated: true, completion: nil)
        }
    }
    func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
        controller.dismiss(animated: true, completion: nil)
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    override func touchesBegan(_ touches: Set, with event: UIEvent?) {
        self.view.endEditing(true)
    }
    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        textField.resignFirstResponder()
        return true
    }

}

Replies

You cannot. See QA1944 Sending SMS Programmatically.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"