问题
An app that I am developing relies on the ability to help users send a mixture of images and text to their friends in one go.
I was hoping that MFMessageComposeViewController would offer some way to provide the user with an image in the body of the message, but evidently I can only suggest NSString for the body.
Alternatively, I could render the text into the image and then send that as well, but I still haven't found a way to suggest that the user send an image via MMS.
Is there a way to do either of these things?
回答1:
I had the same troubles with sending MMS.
I resolved it in this way:
[UIPasteboard generalPasteboard].image = yourImage;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:"]];
So firstly I copied needed image to clipboard and then open standardMFMessageComposeViewController
and paste this image from clipboard.
And of course You should have suitable settings for MMS on your phone.
回答2:
i think, you should use below code. because by default image type is jpeg for png images are not showing in iMessage when you try to paste.
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"aa1" ofType:@"png"]];
[pasteboard setData:data forPasteboardType:@"public.png"];
// or if image is jpeg then below code
[pasteboard setData:data forPasteboardType:@"public.jpeg"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:45263125"]];
回答3:
We cannot send MMS via iOS native SDK.
However we can iMessage a picture to a contact
This Method is tested and verified. I Used it in my code.
if (![MFMessageComposeViewController canSendText]) {
UIAlertView *alertV = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device not support SMS \nOr you
hadn't login your iMessage" delegate:nil cancelButtonTitle:@"Ok" 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"
filename:@"image.jpeg"];
[self presentViewController:mVC animated:YES completion:nil];
You can use any jpeg jpg and png formats.
回答4:
No, you can't send MMS using the iOS SDK.
You can however send both text and images via email using MFMailComposeViewController.
来源:https://stackoverflow.com/questions/10486638/in-the-ios-sdk-how-can-i-help-my-users-send-mms-intermixed-with-sms-from-my-app