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 plugins checkDir() on the following iOS directories to verify that they exist and that I can use the installed plugin:
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 )
I want to use the following method to access and read in the text file:
this.file.readAsText()
But if I try to access the file in each of these directories - for example via the following:
this.file.readAsText(this.file.tempDirectory, 'MyData.txt').then((data) => {})
It errors out with not being able to locate the file.
Bottom line is I do not have the correct path to the text file stored on my iOS device.
Any help on how to determine the path to my text file saved on an iOS device would be greatly appreciated.
Thanks