We’re in the process of creating an iOS app using Phonegap, and are having trouble packaging some premade resources. The app is designed to be used offline, and involves using leaflet.js to display some map layers.
The way we’re doing this is by using .mbtiles files (SQLite files with a specific format), and a custom leaflet.js TileLayer. Currently the base layer is downloaded on first run, however ideally the base layer would be bundled with the app (it is 1-2gb). From what I can tell, this would be fairly easy on iOS as you can just bundle the files as resources, but with Phonegap the APIs only allow access to the Documents directory.
If anyone could shed some light on the best practice for Phonegap bundled assets that would be great!
Let me know if anymore info is needed.
The file system plugins don’t allow access to the read only app bundle, but that isn’t the only way to get data when running in the browser – an XHR to a file url (the app bundle is the parent of the www folder) should work just fine.
That said, a custom plugin seems a better fit in this case. Since the basic requirement is a SQLite database in a custom location, you could try starting with https://github.com/brodyspark/PhoneGap-sqlitePlugin-iOS and modifying the init/openDb code to use a file in the app bundle.
Another option would be to generate all the image files and include those in the app bundle – You’d get better performance that way as SQLite and javascript are not particularly good at handling binary data.
Incidentally, the download on first use approach will likely not pass an app store review if you are putting the file in documents.