I am trying to use the UIActivityViewControllerCompletionHandler
, but i dont quite get how..
I want to detect when the user finishes or dismisses this
Swift 5:
func showShareOf(url: URL, title: String) {
let shareItems: [Any] = ["\(title)\n", url]
let activityVC = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)
activityVC.completionWithItemsHandler = doneSharingHandler
self.present(activityVC, animated: true, completion: nil)
}
@objc func doneSharingHandler(activityType: UIActivity.ActivityType?, completed: Bool, _ returnedItems: [Any]?, error: Error?) {
if (!completed) { return }
// If here, log which activity occurred
print("Shared activity: \(activityType)")
}