Delete a photo from the Photo Library


#1

I have an app that allows the user to take a photo and it gets stored to the Photo Library.
I use the ionic-native PhotoLibrary library to do a “saveImage” to store the Photo in a particular album in the photo library. The reason is so that the user can annotate the photo using the standard IOS features. The user can the upload the photos to the back end and I want to be able to automatically delete the photos once successfully uploaded.

I have tried the following to get the local filesystem path so that I can delete it but I get an error namely “{“code”:5,“message”:“ENCODING_ERR”}” :

this.file.resolveLocalFilesystemUrl(libraryItem.photoURL).then((entry) => {
                console.log("Categories: Photo file path = " + entry);
              }, (reject) => {
                console.log("Categories: Photo file path reject reason = " + JSON.stringify(reject));
              });

Ionic Info:
cli packages: (/Data/Development/IonicApps/FacilitiesManagement/node_modules)

@ionic/cli-utils  : 1.8.1
ionic (Ionic CLI) : 3.8.1

global packages:

Cordova CLI : 7.0.1 

local packages:

@ionic/app-scripts : 1.3.7
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.4.2

System:

ios-deploy : 1.9.1 
ios-sim    : 6.0.0 
Node       : v8.1.3
npm        : 5.3.0 
OS         : macOS Sierra
Xcode      : Xcode 9.0 Build version 9A235