Reputation: 40
I have a question regarding sharing pdf files in swift. Sharing is quite simple and it already works in my app. I receive pdf file from backend, save it to local variable as bytes array, than save it in app cache directory and pass to UIActivityViewController.
Is there any way to receive some callback, that sharing action has been completed, or canceled, so I can immediately remove file from cache?
Thanks in advance for your help.
Upvotes: 0
Views: 557
Reputation: 330
UIActivityViewController
provides a completionWithItemsHandler
property to handle this situation
let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
activityViewController.completionWithItemsHandler = { activityType, userTakeAnyAction, returnedItems, error in
// Clean file here
try? FileManager.default.removeItem(at: url)
}
self.present(activityViewController, animated: true)
Upvotes: 0
Reputation: 56
u could clean your cache when dismissing your UIActivityViewController
Upvotes: 0