Question

I'm currently toying around with Sencha Touch 2.2.1 and am trying to get it to run offline using an HTML5 cache.manifest. Anyone know how to get this to work? I can only find old guides from the last version which no longer seem to work. After some fiddling I have my manifest as follows:

CACHE MANIFEST
index.html
app.js
touch/microloader/development.js

But this seems to throw errors in the development.js script when it attempts to send fetch the app.json file. Are there some Sencha settings I have to adjust for offline mode? Thank you for your help.

Était-ce utile?

La solution

After some hunting around it seems this feature is present in Sencha Touch 2.0 but still a bit incomplete. To get it to work, do as follows:

  1. You must have the Sencha command line installed (which you probably already have since it's required to make a Sencha project in the first place).

  2. Navigate to your project's parent directory in command line

  3. Use the sencha app build production command to "compile" your project into a single file

  4. Navigate to your production directory in YourApp/build/YourApp/production

  5. Chane the extension of cache.appcache to cache.manifest

  6. Edit the index.html file's html tag so that manifest="cache.manifest"

  7. Ensure your server is configured to serve .manifest files correctly

Now your production code should have a working cache manifest. Note you only need to change the extension so that the app works on iOS, it seems to work in browser (or at least Chrome where I tested this) with the .appcache extension.

Compiling to production appears to be the only way to generate a cache manifest file but you can use this same file in a testing build if you don't want all the code minified for debugging. Of course you'll have to copy your manifest over and ensure it's referenced in your testing build's html tag.

All in all Sencha clearly needs to update their documentation here but I'm glad I found this out. I only tested this with a super basic, static, two page application. Hoping it scales decently.

Autres conseils

Instead of changing manually your production package, you should change in app.json lines after 'appCache'. Here is what will be generated by Sencha CMD and will work just fine after running sencha app build production.

You can see a live example here https://github.com/flrent/ConfMate/blob/master/app.json#L79

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top