In the iOS SDK, how can I help my users send MMS intermixed with SMS from my app?
Asked Answered
M

4

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?

Maintopmast answered 7/5, 2012 at 17:47 Comment(0)
C
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.

Cormac answered 13/7, 2012 at 7:52 Comment(0)
C
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"]];
Closeknit answered 9/4, 2013 at 9:6 Comment(0)
U
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.

Undulatory answered 19/12, 2014 at 20:33 Comment(0)
M
0

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

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

Maulstick answered 16/5, 2012 at 22:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.