Is it possible to send an automatic text message to a preset number when a UISwitch is toggled off using Swift, so that a user could be alerted if the app was disabled?
Asked
Active
Viewed 72 times
-3
-
not possible w/o jailbreaking, needs user interaction – Volker Jan 15 '15 at 16:34
-
You can't with the in-built messaging capabilities. You could integrate a 3rd party messaging service. – Paulw11 Jan 15 '15 at 20:44
1 Answers
1
Short Answer
No.
Long Answer
Unfortunately it is not. Not automatically, but you can:
- Schedule a Local Notification with the desired frequency.
- When the user clicks the notification use MessageUI's
MFMessageComposeViewController
.
Warning: don't forget to check if the device MFMessageComposeViewController.canSendText()
To send an SMS using MFMessageComposeViewController you simply have to:
- Set the
body
- Set the
recipients
- Implement the MFMessageComposeViewControllerDelegate Protocol (You don't actually have to but you should)
- Present the View Controller
You may also want to see a question filled with great answers regarding sending text messages programatically!