Does anybody know if it's possible, and how, to programmatically send a SMS from the iPhone, with the official SDK / Cocoa Touch?
Restrictions
If you could send an SMS within a program on the iPhone, you'll be able to write games that spam people in the background. I'm sure you really want to have spams from your friends, "Try out this new game! It roxxers my boxxers, and yours will be too! http://roxxersboxxers.com!!!! If you sign up now you'll get 3,200 RB points!!"
Apple has restrictions for automated (or even partially automated) SMS and dialing operations. (Imagine if the game instead dialed 911 at a particular time of day)
Your best bet is to setup an intermediate server on the internet that uses an online SMS sending service, and send the SMSs via that route if you need complete automation. (ie, your program on the iPhone sends a UDP packet to your server, which sends the real SMS)
iOS 4 Update
iOS 4, however, now provides a viewcontroller you can import into your application. You prepopulate the SMS fields, then the user can iniaite the SMS send within the controller. Unlike using the "sms:..." url format, this allows your application to stay open, and allows you to populate both the to and the body fields. You can even specify multiple recipients.
This prevents applications from sending automated SMS without the user explicitly aware of it. You still cannot send fully automated SMS from the iPhone itself, it requires some user interaction. But this at least allows you to populate everything, and avoids closing the application.
The MFMessageComposeViewController class is well documented, and tutorials show how easy it is to implement.
Limitations to this class
Keep in mind that this won't work on phones without iOS 4, and it won't work on the iPod touch or the iPad. You must either detect the device and iOS limitations prior to using this controller, or risk restricting your app to recently upgraded 3G, 3GS, and 4 iPhones.
However, an intermediate server that sends SMS will allow any and all of these iOS devices to send SMS as long as they have internet access, so it may still be a better solution for many applications. Alternately, use both, and only fall back to an online SMS service when the device doesn't support it.
Did anyone ever find a solution for this? I am aware of breaking out of the app using an sms: url specifier, however I really would like to pre-populate the contents of the SMS, similar to how is possible using mailto:
Thanks
Is there some official statement from Apple about this feature? There is a project called iPhone Delivery Report on Google Code, but it’s only meant for jailbroken phones.
For anyone searching for the SMS API, here is the documentation. Googling a little about the subject, I've found some forums (here and here) talking about CTMessageCenter (from CoreTelephony Framework) in OS 2 and 3, but not working in the new OS. I'm going to test both approaches and comment in this post.
Edit: It's important to note that using API's not released to developers by Apple may incur in your app being blocked, so use this link at your own risk.
Note: I've posted here since I'm note allowed to comment yet.
Here is a tutorial which does exactly what you are looking for: the MFMessageComposeViewController.
http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/
there is a class in iphone 4 which supports to send message with body and recipents from your application .it works the same as sending mail .you can found the documentation here link text
My friends recommended me to try a third party program called Tansee iPhone Transfer SMS,which is a one-click solution when your iPhone text box is full and keeps rejecting receiving any texts.You can transfer the backup of all important iPhone SMS to computer as a txt file or a ANTS file.I have tried its trail version before,and it was downloadable and would keep you SMS in safe.