kimxogus / react-native-version-check

A version checker for react-native applications
MIT License
715 stars 171 forks source link

Android versionCheck.needUpdate() returns undefined #177

Open MichaelAmadheo opened 2 years ago

MichaelAmadheo commented 2 years ago

This is working on iOS but not working for android, it returns undefined

lundjrl commented 2 years ago

@MichaelAmadheo Same here but our app is currently in development and does not have an app store presence on either platform. Is this the same for you?

lapwil commented 2 years ago

yep same for me, but only on development env. everything works on staging and release.

MichaelAmadheo commented 2 years ago

@lundjrl we have the app presence both on Playstore and Appstore. It used to return all the information just like iOS, but just recently it returns undefined and we cannot get the url for playstore

adelchms96 commented 2 years ago

@MichaelAmadheo i solved this by using VersionCheck.getStoreUrl() for android and versionCheck.needUpdate() for ios for now !

NageshA commented 1 year ago

@MichaelAmadheo use the below code. In Android I used was able to solve it by this code latestVersion we need to pass to .needUpdate function.

const res = await fetch(
        `https://play.google.com/store/apps/details?id=${VersionCheck.getPackageName()}&hl=en`,
      );
      const text = await res.text();
      let latestVersion;
      const match = text.match(/\[\[\["([\d.]+?)"\]\]/);
      if (match) {
        latestVersion = match[1].trim();
      }

      let updateNeeded = await VersionCheck.needUpdate({
        latestVersion,
      });