EAS 更新

EAS 更新是一项云服务,为使用 expo-updates 库的项目提供更新。


EAS 更新 是由 EAS(Expo 应用服务)提供的云服务,用于为使用 expo-updates 库的项目提供更新。

EAS 更新让在应用商店提交之间修复小漏洞和快速推送修复变得轻而易举。它通过使应用能够通过空中更新自身的非原生部分(如 JS、样式和图片)来实现这一点。所有包含 expo-updates 库的应用都有接收更新的能力。

🌐 EAS Update makes fixing small bugs and pushing quick fixes a snap in between app store submissions. It accomplishes this by enabling an app to update its own non-native pieces (such as JS, styling, and images) over-the-air. All apps that include the expo-updates library have the ability to receive updates.

快速开始

🌐 Quick start

信息 以下 eas 命令需要 EAS CLI。有关更多信息,请参阅 如何安装 EAS CLI

安装 expo-updates 库并配置 EAS 更新:

🌐 Install the expo-updates library and configure EAS Update:

Terminal
npx expo install expo-updates

eas update:configure

你需要为 Android 或 iOS 创建一个新的构建,以在你的构建中包含 expo-updates 库。之后,你可以向生产渠道推送更新:

🌐 You need to create a new build for Android or iOS to include the expo-updates library in your build. After that, you can push an update to the production channel:

Terminal
eas update --channel production --message "Fix login button alignment"

此命令会发布你的 JavaScript 包和资源,以便用户在下次启动应用时获取新版本。

🌐 This command publishes your JavaScript bundle and assets so users receive the new version on their next app launch.

要获取开始使用 EAS Update 的完整步骤,请参阅 开始使用 EAS Update

🌐 For complete steps to start using EAS Update, see Get started with EAS Update.

主要特点

🌐 Key features

用于更新管理的 JS API

🌐 JS API for update management

更新的 JavaScript API 包含一个名为 useUpdates() 的 React 钩子。该钩子提供有关当前正在运行的更新以及任何可用或已下载的新更新的详细信息。此外,你还可以查看更新过程中遇到的任何错误,以帮助你在应用尝试更新时调试问题。

🌐 The updates JavaScript API includes a React hook called useUpdates(). This hook provides detailed information about the currently running update and any new updates that are available or have been downloaded. In addition, you can view any errors that were encountered during the update process to help you debug any issues while the app is attempting to update.

该 API 还提供了诸如 checkForUpdateAsync()fetchUpdateAsync() 的方法,允许你控制应用检查和下载更新的时间。

🌐 The API also provides methods such as checkForUpdateAsync() and fetchUpdateAsync() which allow you to control when your app checks for and downloads updates.

洞察跟踪

🌐 Insight tracking

你将获得一个部署仪表板,它可以帮助可视化哪些更新正在发送到构建中。更新与洞察配合使用,为你提供关于用户采纳更新情况的数据。

🌐 You'll get a deployments dashboard that helps visualize which updates are being sent to builds. Updates work in concert with insights to provide data on the adoption rates of your updates with your users.

请求标头

🌐 Republish for reverting mistakes

如果更新的效果不如预期,你可以在有问题的版本上重新发布之前的稳定版本,就像在版本控制系统中进行新的“提交”一样。

🌐 If an update isn't performing as expected, you can republish a previous, stable version on top of the problematic one, much like a new "commit" in version control systems.

何时使用 EAS 更新

🌐 When to use EAS Update

ScenarioRecommendation
Fix a bug or crash in JavaScript code and deploy updates in minutes
Update copy, translations, UI styling, or screen layouts
Roll out changes to a percentage of users using rollouts
Publish updates from CI or automated workflows
Test updates with internal teams before production release
Change to native code or native dependencies
Change to app permissions (camera, location, and others)
Update the Expo SDK version
Anything that requires a new app binary version

对于标记为 的情况,请使用 EAS Build 创建并提交新的应用二进制文件。

常见问题

🌐 Frequently asked questions (FAQ)

发布更新时我必须遵循哪些指南?

EAS 更新的规则之一是你需要遵守你所开发的平台和应用商店的规定。这意味着你的更新需要遵循 App Store 和 Play 商店的指南,包括更新内容以及你如何使用它们。这通常意味着对应用行为的更改需要经过审核。

🌐 One of the rules of EAS Update is that you need to follow the rules of the platforms and app stores you are building for. This means your updates need to follow the App Store and Play Store guidelines, including the content of the updates and how you use them. This usually means changes to your app's behavior need to be reviewed.

App Store 的规则经常变化,就像如果你在不使用 Expo 的情况下开发应用一样需要遵守这些规则一样,使用 Expo 和 EAS Update 时也需要遵守这些规则。

🌐 App Store rules regularly change and just as you need to follow them if you were writing an app without Expo, you need to follow them when you are using Expo and EAS Update.

EAS 更新是快速将改进推送给使用你应用的用户的好方法。例如,假设一个应用存在一个需要修复的关键漏洞。使用 EAS 更新,你可以迅速发布修复,并随后提交一个包含修复的新版本。

🌐 EAS Update is a great way to quickly deliver improvements to the people who use your apps. For example, consider an app that has a critical bug that needs to be fixed. With EAS Update, you can quickly get the fix out and later follow up with a new submission that includes the fix built in.

“每月活跃用户”在计费周期内是如何计算的?

信息 注意:1 个每月活跃用户等于在计费周期内至少下载过 1 次更新的一个应用唯一安装。

  • 在结算周期的每一天下载新更新的应用安装计为 1 个月活跃用户。
  • 在结算周期内未下载任何新更新的应用安装计为 0 个月活跃用户。
  • 卸载并重新安装应用(并在你的结算周期内下载每个应用的更新)算作 2 个月活跃用户。
  • 单个设备有两个由单个 Expo 账户拥有的应用,这两个应用都使用更新,则被视为该账户的 2 个月度活跃用户。
我如何为我的应用实现自定义更新策略?

默认情况下,expo-updates 会在每次加载应用时检查更新。你可以使用 Updates API应用配置 实现自定义的更新策略。

🌐 By default, expo-updates checks for updates every time the app is loaded. You can implement a custom update strategy with the Updates API and app config.

我可以在现有的 React Native 项目中使用 EAS Update 吗?

是的。EAS 更新适用于使用 Continuous Native Generation (CNG) 的项目,也适用于已安装 expo-updates 库的 现有 React Native 项目

🌐 Yes. EAS Update works with both projects that use Continuous Native Generation (CNG) and existing React Native projects that have the expo-updates library installed.

我的应用用户需要重新安装应用才能接收更新吗?

不。更新会在应用内下载,并根据你的配置进行应用。应用用户将在下次启动或重新加载应用时看到新版本。

🌐 No. Updates are downloaded inside the app and applied based on your configuration. App users see the new version on their next app launch or reload.

EAS 更新如何处理本地代码的兼容性?

EAS 更新使用 运行时版本策略 来确保更新只发送到与原生代码兼容的构建。如果你的原生代码发生更改,则需要创建新的运行时版本。

🌐 EAS Update uses runtime version policies to ensure updates are only sent to builds with compatible native code. If your native code changes, you create a new runtime version.

我可以在 EAS Workflows 中或通过其他 CI/CD 流水线使用 EAS Update 吗?

是的。EAS Update 可与 EAS Workflows 一起使用。你仍然需要为 Android 或 iOS 配置并创建一个新的构建。之后,你可以将更新任务添加到你的工作流配置中。例如:

🌐 Yes. EAS Update works with EAS Workflows. You still need to configure and create a new build for Android or iOS. After that, you can add an update job to your workflow configuration. For example:

jobs: publish_update: type: update params: message: 'Fix login button alignment' channel: production

有关更多信息,请参见 EAS 工作流程预打包作业

🌐 For more information, see EAS Workflows pre-packaged jobs.

要使用 GitHub Actions 自动发布更新,请参阅 GitHub PR 预览操作 指南。

🌐 To automate publishing updates with GitHub Actions, see the GitHub Action for PR previews guide.

EAS Update 和 CodePush 有什么区别?

EAS 更新是一个原生解决方案,同时也可以与 EAS Build 集成,并提供统一的工作流程。CodePush 使用略有不同的方法。要了解 EAS 更新与 CodePush 之间的区别,请参阅 CodePush 与 EAS 更新的概念性差异

🌐 EAS Update is a native solution that also integrates with EAS Build and provides a unified workflow. CodePush uses a slightly different approach. To learn more about the differences between EAS Update and CodePush, see Conceptual differences between CodePush and EAS Update.

经典更新仍然受支持吗?

经典更新服务在 2021 年 12 月之前可用,现在已被弃用。不能通过 expo publish 发布新更新,但现有应用将继续接收已经发布并正在使用的经典更新。

🌐 The Classic Updates service was available before December 2021 and is now deprecated. New updates cannot be published via expo publish, however, existing apps will continue to receive Classic Updates that have already been published and are actively used.

我们建议过渡到 EAS Update 或使用 自建更新服务

🌐 We recommend transitioning to EAS Update or using a self-hosted update service.

开始使用

🌐 Get started

开始使用 EAS 更新

了解如何开始在项目中配置和使用 EAS Update 所需的设置。

发布更新

了解如何使用 EAS Update 将更新发布到特定分支。

预览更新

使用 EAS 更新查看队友的更改。

使用 GitHub 操作

在提交后发布更新并通过二维码预览。

从 CodePush 迁移

了解如何从 CodePush 迁移到 EAS 更新。

将 EAS 更新与其他 EAS 服务一起使用

要获取有关将 EAS Update 与其他 EAS 服务一起使用的完整教程,请参阅此 EAS 教程。