首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS 6- ChatKit专用接口-发送短信

iOS 6- ChatKit专用接口-发送短信
EN

Stack Overflow用户
提问于 2013-02-11 23:01:29
回答 1查看 3K关注 0票数 4

在iOS 6中,有没有人能够在没有用户交互的情况下通过代码发送短信?

我认为,必须使用ChatKit私有API来实现这一点。然而,苹果似乎在iOS 6中对这个接口做了很大的改变。因此,像https://stackoverflow.com/a/11028230/1884907这样的解决方案在iOS 6上不再有效,因为缺少/更改了类。

(提前说一句:是的,我们都知道苹果拒绝使用私有API的应用,这不是为应用商店准备的)

EN

回答 1

Stack Overflow用户

发布于 2013-02-11 23:55:44

来自另一个StackOverflow帖子here:(代码来自Kaushal Bisht)

代码语言:javascript
复制
// 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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14814729

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档