react-native-version-check icon indicating copy to clipboard operation
react-native-version-check copied to clipboard

Android versionCheck.needUpdate() returns undefined

Open MichaelAmadheo opened this issue 3 years ago • 5 comments

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

MichaelAmadheo avatar Aug 15 '22 02:08 MichaelAmadheo

@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?

lundjrl avatar Aug 26 '22 12:08 lundjrl

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

lapwil avatar Aug 29 '22 15:08 lapwil

@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

MichaelAmadheo avatar Sep 01 '22 08:09 MichaelAmadheo

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

adelchms96 avatar Sep 05 '22 08:09 adelchms96

@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,
      });

NageshA avatar Sep 16 '22 12:09 NageshA