简体   繁体   中英

How do I generate an SMS message based on a template in an iPhone app?

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?

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];

                }

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM