0

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?

4 Answers4

4

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 standard
MFMessageComposeViewController and paste this image from clipboard.
And of course You should have suitable settings for MMS on your phone.

3

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"]];
Hindu
  • 2,894
  • 23
  • 41
1

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.

Zeeshan
  • 4,194
  • 28
  • 32
0

No, you can't send MMS using the iOS SDK.

You can however send both text and images via email using MFMailComposeViewController.

hd1
  • 33,938
  • 5
  • 80
  • 91
David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205