How to get a versionName in react-native app on Android?

后端 未结 8 1174
故里飘歌
故里飘歌 2020-12-25 09:55

I\'ve made a timestamped versionName in build.gradle like 20150707.1125. I want to show the version of the package in react-native app in about window. How I could get vers

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-25 10:14

    I tried most of the thing to fix this nicely and I and happy to see detailed description for doing everything that I needed react-native-version-check

    import { Linking } from 'react-native';
    import VersionCheck from 'react-native-version-check';
    
    VersionCheck.needUpdate()
      .then(async res => {
        console.log(res.isNeeded);    // true
        if (res.isNeeded) {
          Linking.openURL(await VersionCheck.getStoreUrl());  // open store if update is needed.
        }
      });
    

提交回复
热议问题