在iOS SDK中,如何才能帮助我的用户从我的应用程序发送与SMS混合的彩信?

我正在开发的应用程序依赖于帮助用户一次性发送图像和文本混合到他们的朋友的能力。

我希望MFMessageComposeViewController会提供一些方法来为用户提供一个图像在消息的正文,但显然我只能build议NSString的身体。

或者,我可以将文本渲染到图像中,然后发送,但是我仍然没有find一种方法来build议用户通过彩信发送图像。

有没有办法做这些事情?

我发送彩信也有同样的麻烦。
我是这样解决的:

[UIPasteboard generalPasteboard].image = yourImage; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:"]]; 

所以首先我把需要的图像复制到剪贴板然后打开标准
MFMessageComposeViewController并从剪贴板粘贴此图像。
当然,你应该有适合你的手机彩信的设置。

我想,你应该使用下面的代码。 因为在默认情况下,图像types是JPEG格式的图像在尝试粘贴时不会显示在iMessage中。

 UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"aa1" ofType:@"png"]]; [pasteboard setData:data forPasteboardType:@"public.png"]; 

//或者如果图片是jpeg,那么下面的代码

 [pasteboard setData:data forPasteboardType:@"public.jpeg"]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:45263125"]]; 

我们无法通过iOS原生SDK发送彩信。

不过,我们可以将照片发送给联系人

此方法已经过testing和validation。 我在我的代码中使用它。

如果(![MFMessageComposeViewController canSendText]){

  UIAlertView *alertV = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device not support SMS \nOr you 

没有login你的iMessage“委托:nil cancelButtonTitle:@”好的“otherButtonTitles:nil,nil]; [alertv show]; return;}

 MFMessageComposeViewController *mVC = [[MFMessageComposeViewController alloc] init]; mVC.body = @"jjjj"; mVC.recipients = @[@"00XXXXXXXXXX"]; mVC.messageComposeDelegate = self; if ([MFMessageComposeViewController canSendAttachments]) { NSLog(@"ok"); } [mVC addAttachmentData: UIImageJPEGRepresentation([UIImage imageNamed:@"test.jpg"], 1.0) typeIdentifier:@"public.data" 

文件名:@ “image.jpeg”];

 [self presentViewController:mVC animated:YES completion:nil]; 

您可以使用任何jpeg jpg和png格式。

不,您无法使用iOS SDK发送彩信。

但是,您可以使用MFMailComposeViewController通过电子邮件发送文本和图像。