Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you are just looking to send an SMS message in iOS you can use the <code>MFMessageComposeViewController</code> inside of the <code>MessageUI.framework</code>. As you know though, this requires user-interaction.</p> <p>As you had requested, you can use Twilio to send SMS directly using almost any platform. For iOS you can use the following Swift code to hit the Twilio API and send any text messages you'd like:</p> <pre><code>func tappedSendButton() { print("Tapped button") // Use your own details here let twilioSID = "AC8c3...6da3" let twilioSecret = "bf2...b0b7" let fromNumber = "4152226666" let toNumber = "4153338888" let message = "Hey" // Build the request let request = NSMutableURLRequest(URL: NSURL(string:"https://\(twilioSID):\(twilioSecret)@api.twilio.com/2010-04-01/Accounts/\(twilioSID)/SMS/Messages")!) request.HTTPMethod = "POST" request.HTTPBody = "From=\(fromNumber)&amp;To=\(toNumber)&amp;Body=\(message)".dataUsingEncoding(NSUTF8StringEncoding) // Build the completion block and send the request NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: { (data, response, error) in print("Finished") if let data = data, responseDetails = NSString(data: data, encoding: NSUTF8StringEncoding) { // Success print("Response: \(responseDetails)") } else { // Failure print("Error: \(error)") } }).resume() </code></pre> <p>For any further API interaction you can check out the official docs: <a href="https://www.twilio.com/docs/api/rest" rel="noreferrer">https://www.twilio.com/docs/api/rest</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload