In the iOS SDK, how can I help my users send MMS mixed with SMS from my application?

The application I'm developing relies on the ability to help users send a mixture of images and text to their friends at a time.

I was hoping that the MFMessageComposeViewController would offer some way to provide the user with an image in the body of the message, but obviously I can only offer an NSString for the body.

Alternatively, I could display the text in the image and then send it as well, but I still have not found a way to suggest that the user send the image via MMS.

Is there any way to do any of these things?

0
source share
4 answers

I had the same problems sending MMS.
I solved it as follows:

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

So, first I copied the desired image to the clipboard, and then open the standard MFMessageComposeViewController file and paste this image from the clipboard.
And, of course, you must have the appropriate settings for MMS on your phone.

+4
source

I think you should use the code below. because by default the jpeg image type for png images does not appear in iMessage when trying to insert.

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

// or if the image is jpeg, then under the code

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

We cannot send MMS through our own iOS SDK.

However we can iMessage image contact

This method has been 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 

did not log in your iMessage delegate: noil 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.

+1
source

No, you cannot send MMS using the iOS SDK.

However, you can send both text and images by email using the MFMailComposeViewController .

0
source

Source: https://habr.com/ru/post/906109/


All Articles