3 android angularjs ionic-framework
我已经使用Angular和Ionic开发了一个Android移动应用程序。我已经将其上传到以1.0版本运行的Playstore中。现在,我要在Playstore中更新我的应用。
用户更新应用程序时,应清除本地存储。谁能帮助我前进?
我想在每次安装时清除我的应用程序的本地存储。
编辑:在您的应用程序开始的某个地方:
/*your currnt app version,
you should manually update it here*/
var version = "200";
/*get version code stored in localstorage*/
var savedAppVersion = localStorage.getItem("version");
/*if there is one check if it is the same*/
if (savedAppVersion && savedAppVersion === version) {
// do nothing
} else {
/*clear all local storage*/
localStorage.clear();
/*save new code to ls*/
localStorage.setItem("version", version);
}
Run Code Online (Sandbox Code Playgroud)
编辑2:您可以使用cordova插件自动获取应用程序版本: ngCordova
因此,您可以使用$ cordovaAppVersio服务:
$cordovaAppVersion.getVersionNumber().then(function (version) {
// use version here
});
}, false);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2172 次 |
最近记录: |