2012-12-01 28 views
2

任何人都没有在iOS6 .Earlier程序发送短信我用的是核心电话方式发送SMS.It的优良工作到iOS5iOS6我的代码不能正常工作。 我使用以下代码:短信不MFMessgeViewController在iOS 6发送

BOOL成功= [[CTMessageCenter sharedMessageCenter] sendSMSWithText:@“Message”serviceCenter:nil toAddress:@“8800781656”];

我在做什么错?

在此先感谢

+0

如何导入CTMessageCenter头文件。 – Anupama

回答

0

我会做出一个有根据的猜测,苹果已经封闭了API的循环漏洞。他们不希望应用程序在没有用户知识的情况下在后台发送SMS消息。在某些移动网络上,每条短信都会花钱。

+0

这没关系,但黑色,但我已经开发的应用程序,我只是卡在ios 6 only.Please建议或提供代码,如果有可能的话。 –

+0

同意@Black Frog。不知道你的业务逻辑,但如果你可以使用第三方短信服务(通常花费你的钱)),这只是一个调用第三方的API(通常是一个Web API,意味着一个HTTP请求) –

0
// 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 

希望这会帮助你。

+0

我不dont想要使用消息视图controller.I想发送背景的应用程序的短信。 –

+0

在后台发送短信已被Apple限制。如果你想通过你的应用发送短信,这是做到这一点的唯一方法。 –

+0

必须有一些做法 - 越狱iOS设备的biteSMS应用程序在iOS 6中发送SMS(和iMessages)...这只是一个计算/询问如何执行发送的问题。 – ParrotMac