SMS sending without MFMessgeViewController on ios 6

No one sends sms programmatically in iOS6 . I used to use the main telephony method to send SMS. It works fine until iOS5 , but on iOS6 my code doesn't work. I am using the following code:

BOOL success = [[CTMessageCenter sharedMessageCenter] sendSMSWithText: @ "Message" serviceCenter: nil toAddress: @ "8800781656"];

What am I doing wrong?

Thank you in advance

+2
source share
2 answers

I would make a reasonable assumption that Apple closed the hole in its API. They do not want applications to send SMS messages in the background without user knowledge. In some mobile networks, each SMS message costs money.

0
source
 // in .m file -(void)textClicked { controller = [[MFMessageComposeViewController alloc] init]; if([MFMessageComposeViewController canSendText]) { controller.body = @"Whatever you want"; controller.recipients = [NSArray arrayWithObjects:@"", nil]; controller.messageComposeDelegate = self; [self presentViewController:controller animated:YES completion:nil]; } } - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MyApp" message:@"Unknown Error" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; switch (result) { case MessageComposeResultCancelled: NSLog(@"Cancelled"); [alert show]; break; case MessageComposeResultFailed: [alert show]; break; case MessageComposeResultSent: break; default: break; } [self dismissViewControllerAnimated:YES completion:nil]; } // in .h file import MessageUI/MessageUI.h and delegate for Sending Message is MFMessageComposeViewControllerDelegate 

Hope this helps you.

0
source

All Articles