checkVersion.tsx 1.1 KB

1234567891011121314151617181920212223242526272829
  1. import Constants from 'expo-constants';
  2. import * as Linking from 'expo-linking';
  3. import { Alert, Platform } from 'react-native';
  4. export function checkVersion(fetchedVersion: string) {
  5. const currentVersion = Constants.expoConfig?.version;
  6. console.log('currentVersion', currentVersion);
  7. console.log('fetchedVersion', fetchedVersion);
  8. if (currentVersion && currentVersion !== fetchedVersion) {
  9. Alert.alert(
  10. '請更新到最新版本',
  11. 'Please update to the latest version of the app to continue.',
  12. [
  13. {
  14. text: '現在更新',
  15. onPress: () => {
  16. const url =
  17. Platform.OS === 'ios'
  18. ? 'https://apps.apple.com/app/crazy-charge/id6639612402'
  19. : 'https://play.google.com/store/apps/details?id=hk.com.crazycharge';
  20. Linking.openURL(url);
  21. }
  22. }
  23. ],
  24. { cancelable: false }
  25. );
  26. }
  27. }