I am trying to get ionic framework application started, and I want to use file system API in it.
I ran following:
$ionic plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
which seems to have completed without an error. However, when I run the application using local chrome, I get an error on this line:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, ...
Inspecting the console, I see the error is:
ReferenceError: LocalFileSystem is not defined
My question is: what is the correct way to use the file system library in ionic project, and if it's even possible?
Plugins are only used when the app is compiled, not when runned locally from www
folder. If you explore www
folder on your project, you will not find any .js from any plugin. ionic prepare <platform>
is in charge to copy the files from the plugin to the correct location in the native project, before building the final app package.
If you wish to debug a plugin, you can use ripple (a little bit tricky but achievable if you follow Apache Docs, do not try to install the chrome extension as it will probably not be working). Ripple just fakes the functionality of native plugins (does not emulate), so you can debug js layer but you can't test the native one.
Other better solutions would be to use eclipse + chrome remote debugger to debug android apps (have never tried) or xcode + safari to debug ios apps (works fine). Both require authorisation to developer tools on the phone. Also you could try weinre for both platforms but it is not as powerful as chrome/safari.
Weinre, chrome and safari all of them require to compile the app, install on the phone and connect the browser debugger to the running app via usb cable (local wifi network for weinre as it runs under a local server in your local network).