views:

503

answers:

2

Hi

Have anyone tried to use the SDK4's SMS composer? If anyone's got some reference or source code please put in here

Thanks

+1  A: 

If you've got the 4.0 SDK already, check MFMessageComposeViewController. The usage is similar to MFMailComposeViewController.

KennyTM
+2  A: 

If you want to support 3.1 devices, you need to do a few things:

In your target's build settings:

  • set Base SDK to iPhone Device 4.0
  • set iPhone OS Deployment Target to iPhone OS 3.x (the lowest OS level you want to support)

In your target's general settings, under Linked Libraries, change the "Type" next to MessageUI.framework to Weak.

Don't import <MessageUI/MFMessageComposeViewController.h> or it will crash on launch on 3.1. Just import <MessageUI/MessageUI.h>

To make sure it doesn't crash on 3.1.x, you need 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];                
}
chrispix