https://www.wddsss.com/main/displayArticle/267

https://docs.expo.dev/bare/updating-your-app/

https://docs.expo.dev/bare/installing-updates/

https://github.com/expo/expo/blob/master/packages/expo-updates/README.md

此外,你需要将更新和它们各自的资产(JavaScript包、图像、字体等)托管在部署客户端应用程序可以访问的服务器上。expo-cli提供了几个简单的选项:

(1)expo export 创建预构建的更新包,你可以上传到任何静态托管网站(例如GitHub Pages),

(2)expo publish 和部署您的更新到expo的更新服务,这是我们提供的服务的一部分。

react-native 接 expo-update

https://blog.csdn.net/gg_ios/article/details/109206546

code-push

react-native-code-push

  1. import codePush from 'react-native-code-push';
  2. codePush.getUpdateMetadata().then((update: {description: string}) => {
  3. if (update) {
  4. that.setState({
  5. appVersion: update.description
  6. })
  7. }
  8. });

manifest-url

An Expo app manifest is similar to a web app manifest - it provides information that Expo needs to know how to run the app and other relevant data.

When you publish a project you are given a manifest URL. This is where your app will look for updates in the future. The URL you are given is not directly accessible in the web browser without adding some additional headers or parameters.

部分截图:
image.png

一个 Demo:

https://exp.host/@bhaltair/vibra/index.exp?sdkVersion=41.0.0

https://exp.host/@community/native-component-list

https://exp.host/@community/native-component-list/index.exp?sdkVersion=37.0.0


expo publish 后,上传到 aws cloudfront,并且更新 revisionId 字段和别的

https://d1wp6m56sqw74a.cloudfront.net/~assets/3add67963d4e149b704c02aa2b3d3910

expo publish

https://docs.expo.dev/bare/updating-your-app/#served-update-requirements

Android

  1. <meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
  2. <meta-data android:name="expo.modules.updates.EXPO_RELEASE_CHANNEL" android:value="default"/>
  3. <meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="41.0.0" />
  4. <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
  5. <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="300000"/>
  6. <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://kiki-vibra.web.app/android-index.json" />

iOS

  1. <dict>
  2. <key>EXUpdatesCheckOnLaunch</key>
  3. <string>ALWAYS</string>
  4. <key>EXUpdatesEnabled</key>
  5. <true/>
  6. <key>EXUpdatesLaunchWaitMs</key>
  7. <integer>300000</integer>
  8. <key>EXUpdatesSDKVersion</key>
  9. <string>41.0.0</string>
  10. <key>EXUpdatesURL</key>
  11. <string>https://exp.host/@bhaltair/vibra</string>
  12. </dict>

兼容性

Runtime Version

Release Channels

expo publish —release-channel

https://docs.expo.dev/distribution/release-channels/#using-release-channels-in-the-bare-workflow

手动更新

  1. try {
  2. const update = await Updates.checkForUpdateAsync();
  3. if (update.isAvailable) {
  4. await Updates.fetchUpdateAsync();
  5. // ... notify user of update ...
  6. Updates.reloadAsync();
  7. }
  8. } catch (e) {
  9. // handle or log error
  10. }

How Expo Works

Publishing/Deploying an Expo app in Production

image.png

When you publish an Expo app, we compile it into a JavaScript bundle with production flags enabled. That is, we minify the source and we tell Metro to build in production mode (which in turn sets DEV to false amongst other things). After compilation, we upload that bundle, along with any assets that it requires (see Assets) to CloudFront. We also upload your Manifest (including most of your app.json configuration) to our server. This manifest will include a revisionId key which is a unique string (generated by Expo) you can use to identify a specific release of your app, just in case you didn’t increment your app’s version key. When publishing is complete, we’ll give you a URL to your app which you can send to anybody who has the Expo Go app.

As soon as the publish is complete, the new version of your code is available to all your existing users. They’ll download the updated version next time they open the app or refresh it, provided that they have a version of the Expo Go app that supports the sdkVersion specified in your app.json.

Updates are handled differently on iOS and Android. On Android, updates are downloaded in the background. This means that the first time a user opens your app after an update they will get the old version while the new version is downloaded in the background. The second time they open the app they’ll get the new version. On iOS, updates are downloaded synchronously, so users will get the new version the first time they open your app after an update.

卸载 expo-updates

https://github.com/expo/expo/blob/master/packages/expo-updates/README.md

使用 expo-go 扫码

https://expo.dev/@community/native-component-list

https://expo.dev/@bhaltair/vibra
image.png

Hosting Updates on Your Servers

比如 public-url 是 https://kiki-vibra.web.app

https://kiki-vibra.web.app/ios-index.json
https://kiki-vibra.web.app/android-index.json

build

  1. expo build:android --public-url <path-to-android-index.json>
  2. expo build:ios --public-url <path-to-ios-index.json>

术语

standalone apps - 独立应用