3

I have my app in play store. I want to force update the user when a new version is available. To achieve this I want to compare the current installed app version and the version of the play store when the app launches. Looking up version and forcing an update in xamarin But I am not getting any //div[@itemprop='softwareVersion'] tag in the response . Hence I am not getting the version number from play store. Is there any working way to get the current version in play store.

Mili
  • 65
  • 1
  • 5

2 Answers2

2

Hoping that Google won't change the current format for displaying the details of the app, here's the change you have to apply on your code to get the current version:

 @Override
protected JSONObject doInBackground(String... params) {

    try {

        latestVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + context.getPackageName() + "&hl=en")
                .timeout(30000)
                .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
                .referrer("http://www.google.com")
                .get()
                .select("div:containsOwn(Current Version)").next().text();

    } catch (IOException e) {
        e.printStackTrace();
    }
    return new JSONObject();
}
jppavez
  • 21
  • 2
0

Google changed source of Google Play pages and deleted "softwareVersion" tag. According to this thread: Google playstore app version check not working any more if You will add to What's new something like "New Version 1.0.000 any text" then You can do this

newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + MainActivity.myPackageName + "&hl=en")
                .timeout(10000)
                .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
                .referrer("http://www.google.com")
                .followRedirects(true)
                .get()
                .select("content:contains(New Version)")
                .text()
                .split("Version")[1]
                .split(" ")[1]

You will get your full version name without spaces.

I recommend "What's new" method, because no one knows what Google will change inside site source next time.

Zakir Shikhli
  • 397
  • 4
  • 14