I am trying to use a UIActivityViewController
to share an audio file (.aac). It is a temporary file that I have written to the sandboxed documents directory.
I pass a NSURL
in the initWithActivityItem:
method.
[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 press the share button it takes a few seconds and the activity sheet pops up with the only option being Airdrop.
How can I get other options like email or iMessage to show up? Is there a call back method so that I can determine when the "sharing" is finished, so that I can delete the temporary file again?
Is there a way for me to add the audio file without having to write it to disk first? Can't I somehow just pass the NSData
object?
If you are trying to share the actual file, then you need to use UIDocumentInteractionController
, it is designed for sharing entire files. UIActivityViewController
is meant for text and maybe an image.
If you need to message your file rather than just open it another app, then consider making a custom UIActivity
for 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With