How can you send an SMS programmatically to a particular number selected in the contact list in iPhone?
sending sms programmatically in iphone
4k Views Asked by user564963 At
2
There are 2 best solutions below
0

Uh... I think a little discussion would be helpful here. I (maybe mistakenly) take the question, "... send an SMS programmatically ..." to mean sending SMS behind the scenes, w o the MFMessageComposeViewController popping up.
The green checkmark for the answer above is incorrect IF that's the question. I am going to assume that that is the question (I bet I'm not the only one) and offer some bullets to save others the time I have spent getting here.
- There is quiet a bit of discussion in stack that this cannot be done in iOS. and here
- The cordova plugin for Android does it just fine
- the cordova plugin for iOS does not (implying that it cant be done.)
- There is no way the code above runs. Its a sort of pseudo-code. The animated:NO on presentModalViewController, prevents the vc from popping up, but I always end up at didFinishWithResult with MessageCancelled.
- Its right in character for Apple to prevent this.
MFMessageComposeController
is what you're looking for.To send an SMS, you're looking at something like this:
That's the only way to send SMSs from your app at the moment. Unless you just want to open the SMS app. If you aren't worried about the body of the message, you can do this: