0

I need to send sms programmatically.

I found sending programmatically email in google,But did n't found clear info regarding sending sms programmatically.

Can any one pls post some sample code.

Thank u in advance.

Mahesh Babu
  • 3,395
  • 9
  • 48
  • 97

3 Answers3

5

You can prompt the user to send a message with the number to send it to filled out, along with the body of the message, but you cannot send an SMS without the user completing the send.

Matthew Frederick
  • 22,245
  • 10
  • 71
  • 97
1

Here is a perfect blog that can be used to send sms through application. SMS sending through application is introduced with iOS4.0 So you can not use MFMessageComposer in the previous versions of iPhone.

iOS 4 will be the minimum requirement.

hAPPY iCODING...

Suresh Varma
  • 9,750
  • 1
  • 60
  • 91
  • 1
    This will not send an SMS either. It will present the prepared message to send, but it will not send it. – Matthew Frederick Dec 23 '10 at 07:12
  • You cannot send the sms from simulator. For sending SMS you have to test it on real device – Suresh Varma Dec 23 '10 at 07:28
  • It will not send an SMS on a device, it won't send an SMS anywhere, any time. It will present a prepared SMS message with the numbers to send it to and the body of the message filled in, but the user still **must** tap the send button. Go read the blog you linked to, and scroll down to the end. See where it says "Your app should now be able to send SMS **using the new Message UI sheet"** ? That means it presents the message to be sent in a Message UI sheet. It does **not** send it. – Matthew Frederick Dec 23 '10 at 07:49
  • okay got it now Matthew... dat you want to send the SMS without pressing the send button... Dude that thing I say is not possible..... And as per question it was to send SMS programmaticaly (which means as we send the email in our application in the same way we must be able to send SMS from our application) dats what anyone can understand.. and Rest your post says it itself.. – Suresh Varma Dec 23 '10 at 08:40
0
-(void)displaySMSComposerSheet 
{
    MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
    picker.messageComposeDelegate = self;
    NSString *str=@"Your String for SMS"
    picker.body=str;
    [self presentModalViewController:picker animated:YES];
    [picker release];
}

Use this and add framework MessageUI.framework and call this function whenever you want to send message

Matthew Frederick
  • 22,245
  • 10
  • 71
  • 97
dks1725
  • 1,631
  • 1
  • 20
  • 29