iOS file access with @ionic-native/file/ngx/cordova-plugin-file

Hello,

I am trying to read in a text file that is sent via e-mail and then downloaded to an iOS device. Specifically the text file is saved in -“Files icon - On My Phone”.

I am using the following plugin @ionic-native/file/ngx/cordova-plugin-file. I am able to get this to work on Android but I am not sure of the to the location of the file or how to find it?

I have used the checkDir() on the following iOS directories:

  • cordova.file.tempDirectory - Temp directory that the OS can clear at will. Do not rely on the OS to clear this directory; your app should always remove files as applicable. ( iOS , OSX , windows )
  • cordova.file.syncedDataDirectory - Holds app-specific files that should be synced (e.g. to iCloud). ( iOS , windows )
  • cordova.file.documentsDirectory - Files private to the app, but that are meaningful to other application (e.g. Office files). Note that for OSX this is the user’s ~/Documents directory. ( iOS , OSX )

They all exist. But if I try to access the file in each of these directories via the following:

this.file.readAsText(this.file.tempDirectory, 'MyData.txt').then((data) => {})

It errors out with not being able to locate the file.

Any help on how to determine the path to my text file saved on an iOS device would be greatly appreciated.

Thanks

1 Like

I put my answer on stack overflow:

1 Like