![](/img/trans.png)
[英]Get user location while app is background in cordova android application
[英]How to get playstore app verson name and version code android application cordova
我在 Play 商店中有一个应用程序,如何使用 Cordova 获取 Play 商店应用程序版本名称和版本代码,任何建议表示赞赏
要检查更新,您需要采用特定于平台的方法
iOS 方法
https://itunes.apple.com/lookup?bundleId=BUNDLE_ID
发送请求response.data.results[0].version
获取version
,然后将其与本地版本进行比较。https://itunes.apple.com/app/APP_ID
将用户发送到应用商店Android 方法
https://play.google.com/store/apps/details?id=BUNDLE_ID
发送请求https://play.google.com/store/apps/details?id=BUNDLE_ID
将用户发送到应用商店片段
var parser = new DOMParser(),
doc = parser.parseFromString(response.data, 'text/html');
if (doc) {
var tag = doc.querySelectorAll(".hAyfc .htlgb");
if (tag && tag[6]) {
let storeVersion = tag[6].innerText.trim();
if (local_version != storeVersion) {
// send to stroe
}
}
}
Android 方法是一种基于 DOM 的解决方法,因为我们直接使用
tag[6].innerText.trim()
访问索引,但对于 iOS,它是一个可靠的方法。
这是获取 Play 商店应用程序版本号的代码,以及如何实现强制更新选项。 我已经对其进行了测试,并且运行良好。
var your_url =YOUR_PLAY STORE APP_URL;
$.ajax({
url: your_url,
type: 'GET',
success: function(res) {
let storeVersion =null;
var doc=null;
var tag=null;
var parser = new DOMParser(),
doc = parser.parseFromString(res, 'text/html');
if (doc) {
tag = doc.querySelectorAll(".hAyfc .htlgb");
if (tag && tag[6]) {
storeVersion = tag[6].innerText.trim();
}
}
cordova.getAppVersion.getVersionNumber(function(versionNumber){
var curentVersion = versionNumber;
var playStoreVersion = tag[6].innerText.trim();
//alert("loacal version = "+curentVersion+" "+"playstore version = "+playStoreVersion);
if(curentVersion<playStoreVersion){
navigator.notification.confirm("There is New Version of this application available,Click Upgrade to Update now ?", onConfirm, "Confirmation", "Update,Later");
}else{
}
});
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.