79516662

Date: 2025-03-18 07:42:51
Score: 2
Natty:
Report link

I have the same issue. I need to know if the new version of the app is published when I publish the app from the developer console. I have to do some automation. Unfortunately, there is no Official API to fetch the live app version for Android. I use Unity and I need to work in Unity Editor. AppUpdateManager from Android only works on Android Builds.

I solved this issue currently, but it might be changed in the future. It takes the latest version from the App Store and Play Store. I solved this in C# .Net Project. You need to have Newtonsoft.Json and Selenium.WebDriver NuGet package for this to work. Also, you need to pass something like "com.company.project" to the methods below to work.

using System.Collections.ObjectModel;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using Newtonsoft.Json.Linq;

private static async Task<string> GetLatestVersionFromAppStore(string bundleId)
{
    using (HttpClient client = new HttpClient())
    {
        string url = $"https://itunes.apple.com/lookup?bundleId={bundleId}";
        string response = await client.GetStringAsync(url);
        JObject json = JObject.Parse(response);
        string version = json["results"]?[0]?["version"]?.ToString() ?? string.Empty;
        return version;
    }
}

private static string GetLatestVersionFromPlayStore(string packageName)
{
    string url = $"https://play.google.com/store/apps/details?id={packageName}&hl=en";
    var options = new ChromeOptions();
    options.AddArgument("--headless");
    using (var driver = new ChromeDriver(options))
    {
        driver.Navigate().GoToUrl(url);
        
        var button = driver.FindElement(By.XPath("//button[i[contains(@class, 'google-material-icons') and text()='arrow_forward']]"));
        button.Click();

        var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
        
        var isPageLoaded = wait.Until(drv =>
        {
            ReadOnlyCollection<IWebElement> webElements = drv.FindElements(By.ClassName("G1zzid"));
            
            bool areAllElementsDisplayed = webElements.All(element => element.Displayed);
            
            return areAllElementsDisplayed && (bool)((IJavaScriptExecutor)drv).ExecuteScript(
                "return document.readyState == 'complete'");
        });

        var upperElements = driver.FindElements(By.ClassName("q078ud"));
        var lowerElements = driver.FindElements(By.ClassName("reAt0"));
        
        Dictionary<string, string> elements = new Dictionary<string, string>();

        for (int i = 0; i < upperElements.Count; i++)
        {
            elements[upperElements[i].Text] = lowerElements[i].Text;
            
            //Console.WriteLine($"{upperElements[i].Text}: {lowerElements[i].Text}");
        }
        
        return elements.GetValueOrDefault("Version", string.Empty);
    }
}
Reasons:
  • Blacklisted phrase (1): I have to do
  • Blacklisted phrase (0.5): I need
  • Blacklisted phrase (1): I have the same issue
  • Whitelisted phrase (-2): I solved
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): I have the same issue
  • Low reputation (0.5):
Posted by: DeathPro