简体   繁体   English

设置并获取React-Native-Web应用程序的应用程序版本名称和应用程序版本代码

[英]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.

相关问题 react-native-navigation 是否适用于 react-native-web 应用程序? - is react-native-navigation works on react-native-web app? 在反应原生应用程序的 web 版本上使用条带 - Use stripe on the web version of a react native app 有条件地将电子导入 react-native-web 应用程序 - Importing electron conditionally into react-native-web app 如何将react-native-web应用程序部署到heroku中? - How to deploy react-native-web app into heroku? 将 react-native-web 应用程序嵌入到现有网站中 - Embed react-native-web app into existing website 使用来自 react-native-web 应用程序的参数访问 URL - Accessing URL with params from a react-native-web app 是否有任何数据库可用于具有相同代码库的 react-native(ios 和 android)和 react-native-web 应用程序? - Is there any database that we can use for react-native(ios and android) and react-native-web app that have same code base? TypeScript 不解析 react-native-web 代码 - TypeScript not parsing react-native-web code 将react-native-web添加到现有的react-native应用程序时出错 - Error when adding react-native-web to an existing react-native app 在带有react-native-web的create-react-app中与第三方打交道 - Dealing with 3rd parties in create-react-app with react-native-web
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM