{dialog.object}instantUpdateCheckForUpdate Method
Syntax
{dialog.object}.instantUpdateCheckForUpdate(successCallback, errorCallback);
Arguments
- successCallbackfunction
The JavaScript function to call if an update is available. This function will be passed an object that includes a result property that indicates whether or not an update is available.
- errorCallbackfunction
The JavaScript function to call if an error occurs while checking for updates. This function will be passed an error object or string depending on the error.
Description
Checks for updates for a Cordova app with Instant Update.
Discussion
This method allows you check if an update is available in a Cordova application that was build with the Instant Update feature enabled. Since this is an asynchronous operation, you need to provide the JavaScript success and the error callback functions.
If a result is returned within a 5 second time-frame, the successCallback is called and passed an object with a result property that will be either true or false. If true, an update is available. If a timeout or any other error occurs the errorCallback is passed an error object or a string, depending on the error.
This method can be useful if you have turned off auto updates and want to programmatically check if an update is available.
var _successCallbackFunction = function(e) { if(!e.result) { //there is no update available alert('You are running the latest version'); return false; } A5.msgBox.show('Notice','<div style="height: 1in; padding: 15pt;">An update for this application is available. Click OK to install the update.</div>', [{name: 'ok', html: 'OK', value: 'ok'}], function(button) {if(button == 'ok') { setTimeout(function() { {dialog.object}.instantUpdateRefresh() //install the update }, 10) } }); } var _errorCallbackFunction = function() { alert('Could not determine if an update is available.'); } {dialog.object}.instantUpdateCheckForUpdate(_successCallbackFunction, _errorCallbackFunction);
Limitations
Cordova Applications with Instant Update Only
See Also