@arelstone/react-native-versionchecker
Ever needed to check if your app is up to date? No fear, react-native-version-checker
is here!
This is a pure javascript implementation, so it will work with both pure react native and expo
Installation
Yarn:
yarn add @arelstone/react-native-version-checker
npm:
npm install @arelstone/react-native-version-checker
Usage
import { View, Button, Alert, Linking } from 'react-native';
import { VersionChecker } from '@arelstone/react-native-version-checker'
const defaults = {
packageName: 'com.facebook.katana',
countryCode: 'da',
}
const latestVersion = async () => {
const { version } = await VersionChecker.getLatestVersion(defaults);
return console.log(
'VersionChecker',
`Latest version in the store is ${version}`,
);
};
const needsUpdate = async () => {
const { currentVersion, updateNeeded, url, version } = await VersionChecker.needsUpdate(
'2.2.24',
defaults,
);
if (updateNeeded) {
Alert.alert(
'VersionChecker',
`You need to update the app. You are running ${currentVersion}. The lastest version is ${version}`,
[{
onPress: () => Linking.canOpenURL(url).then(yes => {
if (!yes) { return 'Could not open the store'; }
return Linking.openURL(url);
}),
}],
);
}
};
Contributing
Open source development is all about contributions. If you feel that something is missing, feel free to submit a pull request.