[英]Set and get app version name and app version code for react-native-web application
Is there a way to set an app version and build number for a react-native-web app? 有没有一种方法可以为react-native-web应用程序设置应用程序版本和内部版本号?
I am currently using react-native-web
for an app (for IOS, Android and Web). 我目前正在为应用程序(适用于IOS,Android和Web)使用
react-native-web
。
I am also using react-native-device-info
. 我也在使用
react-native-device-info
。
Currently for web when I use: 我目前在网络上使用时:
DeviceInfo.getReadableVersion()
or DeviceInfo.getVersion()
or DeviceInfo.getBuildNumber()
I get only 0.0 and 0. DeviceInfo.getReadableVersion()
或DeviceInfo.getVersion()
或DeviceInfo.getBuildNumber()
我只得到0.0和0。
Getting the version and build number works perfect for android and iOS but I have no idea how to set it and get it for web. 获取版本和内部版本号非常适用于android和iOS,但我不知道如何设置并获取其网络版本。
There is no way to get a version of a website, because there is no .apk or .ipa installed on the browser. 无法获得网站版本,因为浏览器上未安装.apk或.ipa。 I suggest you create your own version system, and put it in some meta tag:
我建议您创建自己的版本系统,并将其放在一些meta标签中:
<meta name="my-app-version" content="1.0.0" />
Also you can do this directly on your JS code: 您也可以直接在JS代码上执行此操作:
export const APP_VERSION = "1.0.0"
Control version in the browser is less required than in the native side. 浏览器中的控件版本比本机端中的控件版本少。 Only do this if you need to force the user to update to the last version, as example: you can force the user to refresh the page and download the last bundle if version is different from and API endpoint that you configured.
仅在需要强制用户更新到最新版本时才执行此操作,例如:如果版本不同于您配置的API端点,则可以强制用户刷新页面并下载最后一个捆绑软件。
Users will eventually refresh or close the tabs of the browser and when they come back, the last version of the code will be available. 用户最终将刷新或关闭浏览器的选项卡,当他们回来时,将提供该代码的最新版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.