1

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,,

Community
  • 1
  • 1
Aldee
  • 4,439
  • 10
  • 48
  • 71

1 Answers1

8

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.

mattjgalloway
  • 34,792
  • 12
  • 100
  • 110
  • using 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? – Aldee Jan 25 '12 at 08:49
  • 1
    @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. – Pangolin Jan 25 '12 at 08:55
  • @LouwHopley ahh.. thanks.. so really, there's no way to send sms through custom interface other than the default message composer interface right? – Aldee Jan 25 '12 at 08:58
  • That's right Aldee. I've edited to show example of copying in from a text field / view. – mattjgalloway Jan 25 '12 at 09:15
  • Now its clear.. thanks LouwHopley... – Aldee Jan 25 '12 at 09:19
  • Yeah, 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. – Pangolin Jan 25 '12 at 09:32
  • I suppose you could set the various fields and then find the method that the "post" button calls and manually call that. – Nate Symer Aug 21 '12 at 21:36
  • Sure, but it's likely an undocumented API and so you won't get an app into the App Store that does that. – mattjgalloway Aug 22 '12 at 21:54
  • Working completely just add [viewController setMessageComposeDelegate:self]; – kb920 Oct 28 '14 at 11:35