iOS: Sending SMS
13,319
It's not possible - you have to use MFMessageComposeViewController
.
Example of using MFMessageComposeViewController
copying your own text in there:
MFMessageComposeViewController *viewController = [[MFMessageComposeViewController alloc] init];
viewController.body = yourTextField.text;
[self presentModalViewController:viewController animated:YES];
where yourTextField
is a UITextField
or UITextView
for user input.
Note you will also want to set the messageComposeDelegate
(probably to self
) and conform to the MFMessageComposeViewControllerDelegate
protocol, in order to know when to dismiss it.
Comments
-
Aldee almost 2 years
Possible Duplicate:
How to programmatically send SMS on the iPhone?Does someone have an idea how to send sms in iOS5 without using the default iPhone/iPad app? I mean in my app, I have a textbox and button. When I hit the button whatever string that the textbox contains will be sent to the specified recipient. Is it possible? thanks,,
-
Aldee about 12 yearsusing that object will cause to display the default message app right? my last option is to copy the stringvalue from the textbox in my app and place it in the message box of the default messaging. is it possible?
-
Pangolin about 12 years@Aldee Mativo, That will allow you to send an sms from within your app. You can also programmatically copy the text from your box into that sms.
-
Aldee about 12 years@LouwHopley ahh.. thanks.. so really, there's no way to send sms through custom interface other than the default message composer interface right?
-
mattjgalloway about 12 yearsThat's right Aldee. I've edited to show example of copying in from a text field / view.
-
Aldee about 12 yearsNow its clear.. thanks LouwHopley...
-
Pangolin about 12 yearsYeah, as far as I can recall there is no other way, else you could just send a 1000 sms'e and bankrupt the user or something. Anyways, no problem.
-
Nate Symer over 11 yearsI suppose you could set the various fields and then find the method that the "post" button calls and manually call that.
-
mattjgalloway over 11 yearsSure, but it's likely an undocumented API and so you won't get an app into the App Store that does that.
-
kb920 over 9 yearsWorking completely just add [viewController setMessageComposeDelegate:self];