-
28 Jan 2013 4:52 AM #1
Unanswered: App in Google play without the 'delta' directory
Unanswered: App in Google play without the 'delta' directory
Regardless of how stupid I feel for getting into this scenario, this is the way things are right now and I need a solution...
I have uploaded a few versions to the Google play store without the 'Delta' directory - which means that upgrading the App does actually nothing, because all files remain at the previous version in localStorage.
The solution I need is creating an update that will clear the localStorage and reload the APP.
Is there any simple way of doing that?
One solution I have tried is using the index.html file. It is never cached ( index.html is included in the HTML manifest ), therefore an inline javascript code can be added to it. I have the following code that clears the local storage on the first time it is being loaded:
The problem is it asks the user to confirm a different Checksum for app.js and app.css files (snapshots are attached).Code:if (typeof localStorage.deltafix == 'undefined') { localStorage.clear(); localStorage.deltafix = true; window.location.reload(); }
Any idea how to prevent that from happening?
app-css.jpgapp-js.jpg
-
28 Jan 2013 5:42 AM #2
I have edited the microloader/development.js file to ignore the confirm message and that prevents the confirm alert...
I am not happy with that solution - but it works (My app doesn't use external JS files - so this solution is safe.) :
UPDATE:Code:if (remoteChecksumBlock !== '/*' + version + '*/') { console.log('found a checksum missmatch - ignoring...'); /* // commented out the confirm alert if (confirm("Requested: '" + asset.uri + "' with checksum: " + version + " but received: " + remoteChecksumBlock.substring(2, version.length) + "instead. Attempt to refresh the application?")) { refresh(); }*/ refresh(); // call refresh() automatically. return; }
My previous solution didn't work with IOS because of some external Phonegap plugins that were collapsing...
What make's this a bit harder, is the fact that even the app.json file is cached in localStorage - so I can't set the 'update: full' settings for app.css & app.js files.
I am now trying to remove the app.json file from local storage, and load a new one.
Is there a way of simply? Anyone?
-
31 Jan 2013 2:11 AM #3
Ok, found a way to go around this issue, and clear app.json, app.js and app.css from local storage of the production build. This is done by modifying the source code of touch/microloader/production.js :
1. Adding a single new line to getManifestStorageKey() function:
2. Adding a single-time procedure to Ext.blink(). The procedure resets all the localStorage entries that contains the ManifestStorageKey string:Code:function getManifestStorageKey(id) { documentUri = documentUri.replace('index.html', ''); // for some reason, the file name in localStorage was index.htmlapp.json, so this fixes that return id + '-' + documentUri + manifestFile; }
Code:Ext.blink = function(manifest) { /* NEW ADDED CODE */ var mykey = 'JsonOverriden'; //define some uniqe key var JsonOverriden = retrieve(mykey); // retrieve(key) is basically: localStorage.getItem(key); var manifestStorageKey = getManifestStorageKey(manifest.id); if (!JsonOverriden){ for (i in localStorage){ var id = manifest.id; if (i.indexOf(id) != -1 ) localStorage.removeItem(i) } store(mykey, true); // save a flag (mykey) localStorage, so this procedure runs only once documentLocation.reload(); return; } /* END OF ADDED CODE */ var manifestContent = retrieve(manifestStorageKey); writeMeta('viewport', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'); writeMeta('apple-mobile-web-app-capable', 'yes'); writeMeta('apple-touch-fullscreen', 'yes'); if (manifestContent) { manifest = new Manifest(manifestContent); blinkOnDomReady(manifest); } else { requestXhr(manifestFile, function(content) { manifest = new Manifest(content); manifest.store(); blinkOnDomReady(manifest); }); } };


Reply With Quote