I followed this tutorial : http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/
and I got the alert ‘Text messaging is not enabled on this device’.
I have imported the MessageUI framework, “MessageUI/MessageUI.h”, and MFMessageComposeViewControllerDelegate in my .h file. From what I read online it seems that people are able to view the MFMessageComposeViewController.
//.h file
#import <UIKit/UIKit.h>
#import "sqlite3.h"
#import <MessageUI/MessageUI.h>
...
@interface DateDetailsViewController : UIViewController <UIActionSheetDelegate, MFMessageComposeViewControllerDelegate, UINavigationControllerDelegate>
...
//.m file
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
controller.body = @"testing";
controller.recipients = [NSArray arrayWithObjects:@"12345678", @"87654321", nil];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
...
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
switch (result) {
case MessageComposeResultCancelled:
NSLog(@"Cancelled");
break;
case MessageComposeResultFailed:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MyApp" message:@"Unknown Error"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
}
break;
case MessageComposeResultSent:
break;
default:
break;
}
[self dismissModalViewControllerAnimated:YES];
}
Is there anything that I’m missing? Thanks in advance.
The MessageUI cannot send SMS from the simulator. Your application needs to be run on an iPhone with SMS service.