I need to share a file (it can be pdf, xlsx or an image) using a Sharesheet. It works on whatsapp or other apps but when I select "mail" only opens mail app but without any attachment. Here is my code:
let myURL = URL(fileURLWithPath: fileURLString)
let activityItems: [AnyObject] = [myURL as AnyObject]
let activityViewController: UIActivityViewController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView=self.view
self.present(activityViewController, animated: true, completion: nil)
(I am running it in the main thread from an asynchronous task)