Skip to content Skip to sidebar Skip to footer

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

Solution 1:

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

iOS Approach

  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 Approach

  1. You need to send a request to https://play.google.com/store/apps/details?id=BUNDLE_ID
  2. Once you get the result, you can extract the version using the snippet below.
  3. Now, if the version is different, you can send the user to the app store using the link 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.

Solution 2:

Here is the code to get the version number of the Play store application, as well as how to implement a force update option. I've tested it, and it is working perfectly.

var your_url =YOUR_PLAYSTOREAPP_URL;
          $.ajax({
            url: your_url,
            type: 'GET',
            success: function(res) {
                let storeVersion =null;
                var doc=null;
                var tag=null;
               var parser = newDOMParser(),
               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{
                }
            });
            }
        }); 

Post a Comment for "How To Get Playstore App Verson Name And Version Code Android Application Cordova"