UIActivityViewController with NSURL for audio file shows only airdrop

I am trying to use the UIActivityViewController to share an audio file (.aac). This is a temporary file that I wrote in the isolated documents directory.

I pass NSURL in the initWithActivityItem: .

 [audioData writeToFile:[urlToAudioFile path] options:NSDataWritingFileProtectionNone error:&error]; UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:@[urlToAudioFile] applicationActivities:nil]; [self.view.window.rootViewController presentViewController:activity animated:YES completion:^{ ... }]; 

When I click the sharing button, it takes a few seconds, and an activity sheet pops up, the only option of which is Airdrop.

How can I get other options like email or iMessage? Is there a callback method so that I can determine when the β€œsharing” is over so that I can delete the temporary file again?

Is there a way to add an audio file without having to burn it to disk? Can't I just pass the NSData object NSData ?

+7
ios ios7 uiactivityviewcontroller
source share
1 answer

If you are trying to share the actual file, you need to use the UIDocumentInteractionController , it is designed to share entire files. UIActivityViewController is for text and possibly image.

If you need to tell your file, and not just open it with another application, consider creating a custom UIActivity for the UIDocumentInteractionController and another for messages and another for mail. See mfmailcomposeviewcontroller and MFMessageComposeViewController

See (Apple Developer): https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDocumentInteractionController_class/Reference/Reference.html

+4
source share

All Articles