Get current and remote version in the native code.
- Current version get from file index.html parse script src
<script type="text/javascript" src="app.js?0.22-544-gd096e48"></script>
- Remote version get from server in this format (new version and note)
0.22-537|0.22-537|This version contains feature updates
If the versions do not equal show native dialog with:
title: "Update Available"
note: "This version contains feature updates"
current: "Current version: 0.22-535"
remote: "Update to: 0.22-537"
buttons: "Update Now" "Cancel"
If user tap "Update Now" we must first of all Sync evals to the server and only then update version.
And in this step maybe:
- builds is OK and we need Sync
- build is broken and we cann't call JS method
So we do test request to the JS
activity.sendJavascript("UART.system.Helper.echo()");
this is method do callback to the native
cordova.version(null, null, 'echo')
and if we get response during 1 second we call JS from native to do Sync
activity.sendJavascript("UART.system.Helper.syncBeforeUpdate()");
after Sync was completed JS will call native
cordova.version(null, null, 'updateTo');
and download zip with new version
This is a plugin implementation of the UpdateTo Version function which can download zip from url and replace www folder at the Cordova project. Also it add url scheme to you APP and then we can start APP from another with zip to download as param - href="myapp://download/version007.zip"
Installation for Android
- Execute in CordovaCLI:
cordova create myApp com.name.product MyAPP
cordova pllatform add android
cordova plugin add https://github.com/lexan1982/cordova-update-www --variable URL_SCHEME=MyAPP
- Go to the folder platforms\android\src\com\ideateam\app
- Rename MyActivity.java to MyAPP.java
- Open MyAPP.java and change class name from MyActivity to MyAPP
public class MyAPP extends CordovaActivity{ ... }
Installation for iOS
Move file MainViewController.m from platforms\ios\ you-package-name \ Plugins\com.ideateam.plugin.version to the directory platforms\ios\ you-package-name \Classes
Call function cordova.version from js code with params:
cordova.version(callback, error, 'isUpdate');
callback - success function
error - error function
action
MyApp