tschoffelen/react-native-check-version

cant get version result in Android

Opened this issue · 4 comments

import { checkVersion } from "react-native-check-version";

const version = await checkVersion();
console.log("Got version info:", version);

if (version.needsUpdate) {
   console.log(`App has a ${version.updateType} update pending.`);
}

RESULT:
Got version info: {"bundleId": null, "country": "us", "error": [Error: App with bundle ID "null" not found in Google Play.], "lastChecked": "2024-04-04T03:59:10.402Z", "needsUpdate": false, "notes": "", "platform": "android", "url": null, "version": null}

you need add manual app id.

import { CheckVersionOptions, checkVersion } from "react-native-check-version";


const options: CheckVersionOptions = {
      bundleId: "com.example.id", // Replace with your bundle ID
    };


const appVersion = await checkVersion(options); // Handle the response
console.log(appVersion);
console.log("App version:", appVersion.version);
console.log("App needs update:", appVersion.needsUpdate);
console.log("Update URL:", appVersion.url);

hi, now it worked but it shows "needsUpdate" true, but i have the latest version.

{"bundleId": "com.project.cronimetcrm", "lastChecked": "2024-04-06T03:50:45.664Z", "needsUpdate": true, "notes": "", "notice": "Invalid version. Must be a string. Got type \"object\".", "platform": "android", "releasedAt": "2024-04-06T03:50:45.663Z", "updateType": "minor", "url": "https://play.google.com/store/apps/details?id=com.project.cronimetcrm&hl=us", "version": "1.0.1"}

*** EDIT ***
i added currentVersion to option and now its shows correct info
{"bundleId": "com.project.cronimetcrm", "lastChecked": "2024-04-06T03:56:42.409Z", "needsUpdate": false, "notes": "", "platform": "android", "releasedAt": "2024-04-06T03:56:42.409Z", "updateType": null, "url": "https://play.google.com/store/apps/details?id=com.project.cronimetcrm&hl=us", "version": "1.0.1"}

great, you need re-run yarn android or npm android. for auto check your bundleId and currentVersion.

const appVersion = await checkVersion(); // now you can remove option

now, the second thing is with IOS.
the error is - Error: App for this bundle ID not found.
this error is not only with "react-native-check-version" package, but also with similar packages.
This is the first time I've received feedback.
And the ios buindleid is different from android.

options:
Object { "bundleId": "com.project.cronimetcrmv2", "country": "et", "currentVersion": "1.0.1", }

result:
Object { "bundleId": "com.project.cronimetcrmv2", "country": "et", "error": [Error: App for this bundle ID not found.], "lastChecked": "2024-04-06T08:28:20.050Z", "needsUpdate": false, "notes": "", "platform": "ios", "url": null, "version": null, }