iOS以编程方式发送消息

时间:2015-06-03 07:00:53

标签: ios

任何人都可以告诉我有没有方法在没有消息编写器的iOS中以编程方式发送短信,如果没有请建议我在iOS应用程序中以编程方式发送短信的任何开源API。

1 个答案:

答案 0 :(得分:1)

您不能自动从iPhone发送短信。 唯一的选择是:

- (void)showSMS:(NSString*)file {

    if(![MFMessageComposeViewController canSendText]) {
        UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device doesn't support SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [warningAlert show];
        return;
    }

    NSArray *recipents = @[@"12345678", @"72345524"];
    NSString *message = [NSString stringWithFormat:@"Just sent the %@ file to your email. Please check!", file];

    MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
    messageController.messageComposeDelegate = self;
    [messageController setRecipients:recipents];
    [messageController setBody:message];

    // Present message view controller on screen
    [self presentViewController:messageController animated:YES completion:nil];
}