UIPasteBoard does not insert audio files?

I am developing an application in which one of the modules is a simple TableView enumeration that shows a list of audio files. When the user selects any audio file, one of the SMS options is included in the action sheet. I need to send a specific audio file via SMS. Please let me know how to do this.

And if this is not possible, provide me the documentation for the apple so that it shows me the evidence.

This is what I tried to insert an audio file ...

First way:

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; NSString *path = [[NSBundle mainBundle] pathForResource:@"audiofilename" ofType:@"caf"]; NSData *myData = [NSData dataWithContentsOfFile:path]; [pasteboard setData:myData forPasteboardType:@"audiofile"]; NSString *copyPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/audiofile.caf"]; NSURL *sndURL = [NSURL fileURLWithPath:copyPath]; [pasteboard setString:[NSString stringWithFormat:@"%@",sndURL]]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"sms:12345678"]]]; 

The second way:

 Class messageClass = (NSClassFromString(@"MFMessageComposeViewController")); if([messageClass canSendText]) { messagepicker = [[MFMessageComposeViewController alloc] init]; messagepicker.messageComposeDelegate = self; UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; NSString *path = [[NSBundle mainBundle] pathForResource:@"290912044119" ofType:@"caf"]; NSData *myData = [NSData dataWithContentsOfFile:path]; [pasteboard setData:myData forPasteboardType:@"audiofile"]; NSString *copyPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/audiofile.caf"]; NSURL *sndURL = [NSURL fileURLWithPath:copyPath]; [messagepicker setBody:[NSString stringWithFormat:@"%@",sndURL]]; [self presentModalViewController:messagepicker animated:YES]; [[UIApplication sharedApplication] setStatusBarHidden:YES]; } 

I know that this is possible by sending to the server and retrieving from there. But this is not a requirement.

Any help would be appreciated, and if that is not possible, please provide documents for Apple.

+6
iphone sms uipasteboard
source share
1 answer

It is not possible to send an audio file from a message with the current sdk .... You can achieve this requirement by uploading this audio file to the server, and then send this URL from the message.

+1
source share

All Articles