When a new software update is available, if user has data stored in jsonstore I need to allow user to commit them to the server before applying the software update, so his/her uncommited updates don't get lost. Currently user is unable to use the application until the update is installed.
Is there a way to execute JavaScript code before updating the application so I can initialize the jsonstore, take the data and send to the adapter before performing the update installation?
We saw that the "unload" and "beforeunload" events are fired before a DirectUpdate. Maybe this is an option for code if the data is still available in memory at that point in time?
WL 5.0.6.1 Android - Direct Update keeps Native/Cordova resources active/in memory (e.g. BusyIndicator) but reference is lost
There is no programmatic hook available for a developer to use in order to perform an action prior to a Direct Update request.
That said, a Direct Update does not take place during runtime per-se, rather only:
So from what I understand, only the second scenario above is not being handled.
In the first scenario the user did not yet perform any data manipulations.
Not sure I completely understand the scenario, as you didn't elaborate much, but...
A possible solution would be to use the Cordova Events API (pause, resume).
In theory, you could detect the case where the application was tasked with moving to the background and hopefully save the user data in a secondary collection before that.
And so, when the app is resumed but a Direct Update request has arrived and the primary collection was not previously saved/synced with the server (check with some flag, maybe?) then you could restore the app state using the secondary collection; essentially resume the app with the "unsaved" user data despite the Direct Update request. You/the user could then save and sync the data.
Or something like that.
Feel free to also submit a feature request.