如何在Android上的react-native应用程序中获取versionName?
问题描述:
我在build.gradle中制作了带有时间戳的versionName,例如20150707.1125.我想在关于"窗口的react-native应用程序中显示该软件包的版本.如何在代码中获取versionName?
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 versionName in code?
答
我已成功使用 React Native Device信息组件,以获取Gradle配置中指定的构建详细信息.
I've successfully used the React Native Device Info component to get the build details as specified in the Gradle config.
安装后,您可以使用:
DeviceInfo.getVersion()
要输出版本,并且:
DeviceInfo.getBuildNumber()
获取内部版本号.