如何获取Playstore应用Verson名称和版本代码Android应用Cordova [英] How to get playstore app verson name and version code android application cordova

查看:57
本文介绍了如何获取Playstore应用Verson名称和版本代码Android应用Cordova的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Play商店中有一个应用程序,如何使用Cordova获取Play商店应用程序的版本名称和版本代码,对任何建议表示赞赏

i have one app in the play store, how can get play store application version name and version code using Cordova, any suggestion appreciated

推荐答案

要检查更新,您需要采用特定于平台的方法

To check updates, you need to take a platform-specific approach

iOS方法

  1. 您需要向 https://itunes.apple.com/lookup?bundleId=BUNDLE_ID
  2. 发送请求
  3. 获得结果后,您可以从 response.data.results [0] .version 中获取 version ,然后将其与本地版本进行比较.
  4. li>
  5. 现在,如果版本不同,则可以使用链接 https://itunes.apple.com/app/APP_ID
  6. 将用户发送到应用商店.
  1. You need to send a request to https://itunes.apple.com/lookup?bundleId=BUNDLE_ID
  2. Once you get the result, you can fetch the version from response.data.results[0].version and then compare it with the local version.
  3. Now, if the version is different, you can send the user to the app store using the link https://itunes.apple.com/app/APP_ID

Android方法

  1. 您需要向 https://play.google.com/store/apps/details?id=BUNDLE_ID
  2. 发送请求
  3. 获得结果后,您可以使用下面的代码段提取版本.
  4. 现在,如果版本不同,则可以使用链接 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,这是一个可靠的索引.

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.

这篇关于如何获取Playstore应用Verson名称和版本代码Android应用Cordova的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆