The SMS
URL scheme does not provide any means of filling the SMS body. Thus your only option to pre-fill the sms is to use the MFMessageComposeViewController
You can set the text message body using the Messaging framework, you will need to added this to framework. Add the #import <MessageUI/MessageUI.h>
to the import list.
make sure that the view controller implements MFMessageComposeViewControllerDelegate
, this is needed to dismiss the MFMessageComposeViewController
.
The implement for MFMessageComposeViewControllerDelegate
:
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
[controller dismissModalViewControllerAnimated:YES];
}
Then in the method that will display the message composer place this code:
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;
messageController.body = @"Your message here.";
messageController.recipients = [NSArray arrayWithObject:@"9016098909891"];
[self presentModalViewController:messageController animated:YES];
[messageController release], messageController = nil;