I am working on an App showing an Info Panel based on pictograms. I am given the user the option to select a pictogram from Photo Library and showing it in the App. As part of the process I am recovering the filename, so that I am able to present the name of the pictogram together with the image.
I am using UIImagePickerController to pick the image from Photo Library and PHAsset to gather the filename:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let asset = info[UIImagePickerControllerPHAsset] as? PHAsset {
let assetResources = PHAssetResource.assetResources(for: asset)
print(assetResources.first!.originalFilename)
}
dismiss(animated: true, completion: nil)
}
This solution is working fine in XCode simulator with iOS 13.2. However, it is not working in an Ipad running iOS 13.3 In the latter case I have realized the filename is being changed at the time I upload the file to Photo Library. As a result I am recovering a generic name such as IMG_001 or IMG_052 (file:///var/mobile/Media/DCIM/100APPLE/IMG_001.png)
I have checked all metadata from assetResources and I have verified both filename and URL attributes are registering this generic name. I have also tested that I am getting that name when I am importing the file from Ipad Photo Library into my MacOS. However, if I access the file from Ipad File Manager utility I am seeing the right one.
Therefore it seems iOS13.3 is changing the filename as part of the uploading process to Photo Library. I would really appreciate some insights regarding how to recover the original filename.
Thanks in advance