Selecting an image on iOS. PHAsset returned instead of file location or image source



I’m converting my Android application to iOS and ran into an error when selecting an image from the device library. To pick the image I use NativeScript Image Picker and the following code:

var context = imagepicker.create({ mode: "single" });
    .then(function() {
        return context.present();
    .then(function(selection) {
        selection.forEach(function(selected) {
            var imageFromLocalFile;
                imageFromLocalFile = imageSourceModule.fromFile(selected["_ios"]);
            } else if ({
                imageFromLocalFile = imageSourceModule.fromFile(selected["_android"]);
            settings.contactPhoto = imageFromLocalFile.toBase64String("png");
    }).catch(function (e) {
        console.log("imageTap error: " + e);

On Android imageFromLocalFile would return “/storage/emulated/0/Pictures/Screenshots/Screenshot_20180729-175453.jpg”.

On iOS however I get this:

<PHAsset: 0x7faeeee97150> ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED/L0/001 mediaType=1/0, sourceType=1, (3000x2002), creationDate=2012-08-08 21:55:30 +0000, location=1, hidden=0, favorite=0

I’ve looked around but can’t find a clear or up to date answer. How do I turn this string (I assume it’s and PHAsset?) into a file location and ultimately an image source?

Any help is greatly appreciated, thanks in advance!


It’s not a issue, simply that is how iOS works. If you want to retrieve file path, you will have to access PHAsset apis.


How would I do this? I didn’t find an answer that figured it out yet.