0

Installed version and Appstore version seems to be same but in last few days we are facing force update in our app randomly

var version = await Task.Run(async () =>
{
    var uri = new Uri($"https://play.google.com/store/apps/details?id={PackageName}&hl=en");
    using (var client = new HttpClient())
    using (var request = new HttpRequestMessage(HttpMethod.Get, uri))
    {
      request.Headers.TryAddWithoutValidation("Accept", "text/html");
      request.Headers.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0");
      request.Headers.TryAddWithoutValidation("Accept-Charset", "ISO-8859-1");
      using (var response = await client.SendAsync(request).ConfigureAwait(false))
      {
            try
            {
                response.EnsureSuccessStatusCode();
                var responseHTML = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
                var rx = new Regex(@"(?<=""htlgb"">)(\d{1,3}\.\d{1,3}\.{0,1}\d{0,3})(?=<\/span>)", RegexOptions.Compiled);
                MatchCollection matches = rx.Matches(responseHTML);
                return matches.Count > 0 ? matches[0].Value : "Unknown";
            }
            catch
            {
                return "Error";
            }
          }
      }
   }
);

When matches returns unknown because matches count sometime getting 0 values Can anyone facing this issue and how could resolve this issue. Thanks Advance.

Dev Xam
  • 53
  • 7
  • so you're screen scraping and sometimes your Regex doesn't work? This really has nothing to do with Xamarin. Have you captured the HTML for the cases where it doesn't work and checked the content to see what is different than the cases that do work? That would seem like the logical next step. – Jason May 26 '22 at 13:04
  • Perhaps timeout or other http problem? Sounds like you need a way to log the response, when there are no matches. – ToolmakerSteve May 26 '22 at 19:51
  • @Jason Seems to be changed the HTML content in the play store app. I have struck at the moment if any idea how to fix this. currently, we are not getting App information in playstore app – Dev Xam May 27 '22 at 06:53
  • So the version code you get from the html force the app to update, you can change the way of getting the version code. You can check this [link](https://stackoverflow.com/questions/34309564/how-to-get-app-market-version-information-from-google-play-store). – Liyun Zhang - MSFT Jun 01 '22 at 05:30

0 Answers0