如何从iPhone应用程序发送彩信(MMS)

8
在我的新iOS项目中,我希望最终用户能够在UIButton操作中发送MMS文本和/或图像(来自TextField)。我见过类似的应用程序具有此功能(有文本,但还没有看到过带有图像的应用程序)。
我已经在谷歌上搜索了,但找不到如何做到这一点,非常感谢任何帮助。
1个回答

18

这将会完美地运行

MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; 
pasteboard.persistent = YES;
pasteboard.image = [UIImage imageNamed:@"PDF_File.png"];

NSString *phoneToCall = @"sms:";
NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];
[[UIApplication sharedApplication] openURL:url];    

if([MFMessageComposeViewController canSendText]) {
    NSMutableString *emailBody = [[NSMutableString alloc] initWithString:@"Your Email Body"];
    picker.messageComposeDelegate = self;
    picker.recipients = [NSArray arrayWithObject:@"123456789"];
    [picker setBody:emailBody];// your recipient number or self for testing
    picker.body = emailBody;
    NSLog(@"Picker -- %@",picker.body);
    [self presentModalViewController:picker animated:YES];
    NSLog(@"SMS fired");
}

在您的文本框中,点击文本框并粘贴。 - Manu
非常感谢。我期待着测试这段代码。我很感激你的帮助。 - Gregory Ortiz
4
如果我理解正确,您的意思是最终用户必须手动粘贴它。是否有任何编程方法可以实现这一点? - Rob
@Rob:如果我对你有所帮助,可以投票吗? - Manu
@VenkatManohar 原则上同意,但实际上我没有看到令普通iOS开发人员感到合理的引人注目的Web服务解决方案。我们真的希望有一些东西,可以无缝地发送MMS(不需要愚蠢的用户干预,但也不会被卷入金融交易)。除了在某些基于云的服务上暂存图像,然后只是SMS URL(即使那也很不优雅)之外,没有任何解决方案符合这一要求。 - Rob
显示剩余4条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接