[英]How to get playstore app verson name and version code android application cordova
i have one app in the play store, how can get play store application version name and version code using Cordova, any suggestion appreciated我在 Play 商店中有一个应用程序,如何使用 Cordova 获取 Play 商店应用程序版本名称和版本代码,任何建议表示赞赏
To check updates, you need to take a platform-specific approach要检查更新,您需要采用特定于平台的方法
iOS Approach iOS 方法
https://itunes.apple.com/lookup?bundleId=BUNDLE_ID
https://itunes.apple.com/lookup?bundleId=BUNDLE_ID
发送请求version
from response.data.results[0].version
and then compare it with the local version.response.data.results[0].version
获取version
,然后将其与本地版本进行比较。https://itunes.apple.com/app/APP_ID
https://itunes.apple.com/app/APP_ID
将用户发送到应用商店Android Approach Android 方法
https://play.google.com/store/apps/details?id=BUNDLE_ID
https://play.google.com/store/apps/details?id=BUNDLE_ID
发送请求https://play.google.com/store/apps/details?id=BUNDLE_ID
https://play.google.com/store/apps/details?id=BUNDLE_ID
将用户发送到应用商店snippet片段
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 approach is rather a DOM-based workaround as we are accessing the index directly using
tag[6].innerText.trim()
, but for iOS, it's a solid one.Android 方法是一种基于 DOM 的解决方法,因为我们直接使用
tag[6].innerText.trim()
访问索引,但对于 iOS,它是一个可靠的方法。
Here is the code to get the version number of the Play store application, as well as how to implement a force update option.这是获取 Play 商店应用程序版本号的代码,以及如何实现强制更新选项。 I've tested it, and it is working perfectly.
我已经对其进行了测试,并且运行良好。
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.