I would like to be able to share an audio file to Twitter, Facebook etc. using either UIActivityViewController or UIDocumentInteractionController when a user presses a share button for an audio clip which is played by being streamed remotely via AVPlayer.
Ideally when the share button is pressed I would to present the user with options for sharing via Twitter, Facebook etc. and then once they select the option - download the file. Conversely I can download the file before hand which is the simpler solution.
This is my attempt where I download the audio file first, which doesn't enable sharing via Twitter or Facebook.
let item: [Any] = [url] // URL path to where audio file is written to
let avc = UIActivityViewController(activityItems: item, applicationActivities: nil)
self.present(avc, animated: true)
I'm surprised at how challenging this has been. If only it was as easy as sharing an image! Help greatly appreciated