2013-02-11 67 views
4

有没有人管理尚未发送iOS 6用户交互的代码短信?iOS 6 - ChatKit私人API - 发送短信

我认为,必须使用ChatKit私有API来执行此操作。但是,似乎Apple在iOS 6中更改了这个API。因此,类似https://stackoverflow.com/a/11028230/1884907的解决方案由于丢失/更改了类而不再适用于iOS 6。

(只需提前:是的,我们都知道,苹果拒绝使用私有API的应用程序,它不是应用商店)

+0

您是否在此找到解决方案? – newenglander 2013-07-24 09:26:07

回答

1

从另一个StackOverflow的后here:(代码从Kaushal Bisht)

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

虽然您不能在后台发送短信。我希望这有帮助。

+1

谢谢,但我担心这会显示消息视图控制器。目的是在没有用户交互的情况下发送短信。它必须以某种方式与ChatKit API一起工作,但我想没有人知道如何。 – 2013-02-12 08:12:05

+0

就像我之前说过的,苹果不会让你在后台发送它,因为用户需要知道他们发送了什么,因为他们将收取费用,你必须通过登录的电子邮件应用程序发送消息或苹果短信/ imessage应用程序。对不起,但这是为了用户的安全。 – Comradsky 2013-02-20 15:33:03

+0

这关于App Store中的公共应用程序,这很好。 但我敢肯定,必须有一种使用私有API的非官方方式。例如,也可以发起和接受电话并通过私人API挂断。当然,使用这些API的应用程序不会获得App Store的批准,所以用户没有问题。 但重要的是要知道,并非所有开发的应用程序都适用于App Store中的公开发布。有些是为了公司内部的目的,这就是为什么我们需要这些功能并知道如何访问它们的原因。 – 2013-03-04 08:48:24