I'm developing Cloud based Chatting app (like Facebook Messenger), In that We want to include feature like auto download (and store) photo-video to Photo Library. I can store image or video via following code to Photo Library once.
func savePhoto() {
if let assetCollection = fetchAssetCollectionForAlbum() {
PHPhotoLibrary.shared().performChanges {
let assetChangeRequest = PHAssetChangeRequest.creationRequestForAsset(from: image)
let assetPlaceHolder = assetChangeRequest.placeholderForCreatedAsset
let albumChangeRequest = PHAssetCollectionChangeRequest(for: assetCollection)
let enumeration: NSArray = [assetPlaceHolder!]
albumChangeRequest!.addAssets(enumeration)
} completionHandler: { (flag, error) in
if error == nil {
HapticHelper.shared.generate(feedbackType: .notificationSuccess)
}
else {
HapticHelper.shared.generate(feedbackType: .notificationError)
}
}
}
}
But When user choose to auto download (and store) photo-video to Photo Library then How can I identify that this image is already stored in library previously?
May some kind of identifier or something else which tells me that from this URL path image is already stored or not.