0

I'm trying to make an iPhone app where a user can use a built-in template for sending SMS messages. For example:

Dear [recipient name]

I would like to meet you.

Yours sincerely,

[recipient name]

I want to change [recipient name] to the person the user is sending the SMS message to.

How would I generate the string to be sent in the SMS message, and how would I send it?

Brad Larson
  • 170,088
  • 45
  • 397
  • 571

2 Answers2

1

if any one looking for the code i have done it myself.

if (appdelegate.dataarray.count>0) { NSMutableArray *dataarrrr = [appdelegate.dataarray objectAtIndex:0]; NSLog(@"%@",[dataarrrr objectAtIndex:0]); NSString *aa = [dataarrrr objectAtIndex:0]; NSMutableArray *myArray = [aa componentsSeparatedByString:@","];

            NSString *n = [myArray objectAtIndex:0];
            NSString *m=[myArray objectAtIndex:1];
            NSString *Message = [dataarrrr objectAtIndex:1];
            NSString *new = [Message stringByReplacingOccurrencesOfString: @"<Dear User>" withString:n];
            controller.body = new;
            controller.recipients= [NSArray arrayWithObject:m];
            controller.messageComposeDelegate = self;
            [self presentModalViewController:controller animated:YES];

                }
0

See the MFMessageComposeViewController, you can set the SMS body before displaying the message composer. I don’t think there’s a better way to send text messages, see this related question.

Community
  • 1
  • 1
zoul
  • 102,279
  • 44
  • 260
  • 354
  • the problem is that u can not change the body of the sms after u click the name of recipient. i want to change body of sms after i select a person whom i wanted to send sms. – Syed Faraz Haider Zaidi Jan 20 '11 at 08:23
  • 3
    @Syed if you want that, then present the address book yourself, preset the body and have at it. No way apple is gonna let you programmatically modify a message that user thinks she's sending after the fact. – Jason Coco Jan 20 '11 at 08:28