I've created this function for sharing image, but I have a problem.
func shareImg(img: UIImage) {
let imageShare = [ img ]
let activityViewController = UIActivityViewController(activityItems: imageShare as [Any] , applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
activityViewController.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
activityViewController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.init(rawValue: 0)
activityViewController.completionWithItemsHandler = { (type, _, _, error) in
print(error)
}
self.present(activityViewController, animated: true, completion: nil)
}
Every time I try to save image to photo library it gives me this error and it isn't saved.:
Error Domain=ALAssetsLibraryErrorDomain Code=-1 "Unknown error" UserInfo={NSLocalizedDescription=Unknown error, NSUnderlyingError=0x282e0ff60 {Error Domain=PHPhotosErrorDomain Code=3303 "(null)"}}
I've found that code 3303 refers to:
ALAssetsLibraryWriteIncompatibleDataError
And also it logs this into console:
[ShareSheet] connection invalidated
Can anyone please help me? Thanks in advance