In order to support iPhone OS 3.x and 4.0 I programmatically control MFMessageComposeViewController functionality like this (use it only if the OS version is 4.0 or above):
You need to make sure you're doing a few things:
In your target's build settings:
In your target's general settings, under Linked Libraries, change the "Type" next to MessageUI.framework to Weak.
Don't import
or it will crash on launch in 3.x. Just import
I don't know what os_version_num is, but here's the code I use to test for the availability of MFMessageComposeViewController:
Class smsClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (smsClass != nil && [MFMessageComposeViewController canSendText]) {
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
controller.body = text;
controller.recipients = [NSArray arrayWithObjects: nil];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
[controller release];
}