0

Since ALAssetLibrary Api is deprecated we are using PHPhotoLibrary to save images to PhotoAlbum

If we use ALAssetLibrary,we can able to get assetUri of the saved image, but we cannot able to get the same if we use PHPhotoLibrary .

Example For assetUri-

/Library/Developer/CoreSimulator/Devices/1ABD9386-B868-4B8D-9670-3F260D574569/data/Media/DCIM/100APPLE/

Is there another way to get the same path as mentioned above using PHPhotoLibrary?

Thanks in Advance

VenkyDhana
  • 905
  • 5
  • 16

1 Answers1

0

AssetUri is not available with PHPhotoLibrary .

We can use request.PlaceholderForCreatedAsset.LocalIdentifier instead.

UIImagePickerController controller = new UIImagePickerController {
      SourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum,
      ImagePickerControllerDelegate = new PickerDelegate(),
      MediaTypes = new string[] { UTType.Image }
};
this.PresentViewController(controller, true, null);


public class PickerDelegate: UIImagePickerControllerDelegate
{
    public override void FinishedPickingImage(UIImagePickerController picker, UIImage image, NSDictionary editingInfo)
    {
        PHPhotoLibrary.SharedPhotoLibrary.PerformChanges(
            () => {
                PHAssetChangeRequest request = PHAssetChangeRequest.FromImage(image);
                string id = request.PlaceholderForCreatedAsset.LocalIdentifier;
            },
            (bool success, NSError error) => {
            }
        );
    }
}

Refer to

How to get the URL of an image just added in PHPhotoLibrary

Get URL of a newly created asset, iOS 9 style

ColeX
  • 14,062
  • 5
  • 43
  • 240