Ship over-the-air updates to a phone app
The platform can serve over-the-air updates to phone apps built with Expo. Most releases of such an
app change only JavaScript and images; with app updates they reach phones without a new store build
or APK. The phone app uses the open-source expo-updates library and the open Expo Updates protocol,
and the platform serves the updates itself. This page is the how-to, done with fcdev updates.
The terms
Section titled “The terms”| Term | Meaning |
|---|---|
| Application | The platform application that owns the phone app, named by its code (acme). |
| App key | One phone app of the application (driver-app). An application may have several. |
| Runtime version | The native code an update needs, set when the binary is built (1.4.0). An update reaches only binaries of its runtime version. |
| Channel | Set in the binary (production, staging). Phones on a channel get that channel’s updates. |
| Branch | One app key, platform (android or ios), runtime version and channel. Updates are published to a branch. |
| Update | One expo export of the app for one platform, published to a branch. Immutable. |
A phone asks at launch whether its branch has a newer update, downloads it, checks its signature, and runs it on the next start. The newest update of a branch is live.
Every manifest the platform sends is signed. The app embeds a certificate and refuses anything the matching key did not sign, so the update addresses are public.
1. Create a signing key and certificate
Section titled “1. Create a signing key and certificate”Do this once per key:
fcdev updates keygen --key-id main --common-name "acme driver-app updates" --years 10 --out-dir ./keys| Flag | Default | Use |
|---|---|---|
--key-id |
main |
The key id the app names in codeSigningMetadata.keyid. Letters, digits, ., _ and - only. |
--common-name |
app updates |
The certificate’s common name. |
--years |
10 |
How long the certificate is valid, from 1 to 30. |
--out-dir |
. |
Where private-key.pem and certificate.pem are written. It refuses to overwrite either. |
The command writes a 2048-bit RSA key (private-key.pem, mode 0600) and a self-signed code-signing
certificate (certificate.pem).
- The private key goes in the platform’s secret store, and the platform’s operator names it in
FC_APP_UPDATES_SIGNING_KEYSas<key-id>=<source>, where the source isaws-sm://...,aws-ps://...,env:NAMEorfile:/path. With no key configured the update routes answer503. Keep old key ids while binaries that embed their certificates are in use, and never put a different key behind an existing id. - The certificate goes into the app. When it expires every update stops, so build the next binary before that.
2. Configure the app
Section titled “2. Configure the app”In app.json:
{ "expo": { "runtimeVersion": "1.4.0", "updates": { "url": "https://platform.example.com/app-updates/acme/driver-app/manifest", "requestHeaders": { "expo-channel-name": "production" }, "codeSigningCertificate": "./certificate.pem", "codeSigningMetadata": { "keyid": "main", "alg": "rsa-v1_5-sha256" } } }}The update URL is /app-updates/<application code>/<app key>/manifest on the platform. Build the
binary as usual (npx expo prebuild, Gradle, Xcode).
3. Give the pipeline a credential
Section titled “3. Give the pipeline a credential”The application’s own service account may publish, roll out and roll back its own application’s
updates (role platform:application-service). Operators hold platform:app-update-admin. Point
fcdev at a shared platform with a profile (--profile prod): see
work against a remote platform. Against a local fcdev no profile
is needed.
4. Publish an update
Section titled “4. Publish an update”npx expo export --platform android --platform ios --output-dir distnpx expo config --type public --json > dist/expoConfig.jsonfcdev updates publish dist --app acme --app-key driver-app --channel production \ --runtime-version 1.4.0 --message "Fix the delivery list" --commit "$GIT_SHA" --profile prodThe command uploads only the files the platform does not have, then publishes one update per
platform; each is live when the command returns. An export does not record its runtime version: pass
--runtime-version (or --runtime-version-android and --runtime-version-ios when they differ), or
let the command read a plain runtimeVersion from expoConfig.json. It refuses to publish without
one, and from an export that is not well formed. --os android|ios|all limits the platforms, and
--expo-config names the app config file when it is not <export-dir>/expoConfig.json.
fcdev updates list --app acme shows what was published, by whom, and what is live;
fcdev updates branches --app acme shows each branch and what it serves.
5. Stage a rollout
Section titled “5. Stage a rollout”--rollout 10 on publish sends the update to 10% of the branch’s phones. A phone’s share is fixed
per update, so it does not flap between launches. Widen it with:
fcdev updates rollout <updateId> 50fcdev updates rollout <updateId> 100Only the newest update of a branch can be partial, and a new publish waits until it is at 100% or rolled back. Lowering a share does not take the update off phones that already have it.
6. Roll back or republish
Section titled “6. Roll back or republish”| Command | What phones get |
|---|---|
fcdev updates rollback --app acme --app-key driver-app --os android --runtime-version 1.4.0 --channel production |
The update before the current one, published again as a new update (a phone only moves forward to a newer update). |
fcdev updates rollback ... --to-embedded |
The bundle built into the binary. Publishing a new update ends it. |
fcdev updates republish <updateId> |
Any earlier update of the branch, again as a new update. |
rollback and republish take --message to record why. Every publish, rollout change and rollback
is in the audit log.
7. Publish Android binaries and hand out an install link
Section titled “7. Publish Android binaries and hand out an install link”People who install the app outside a store get it from an install link: one address per phone app
and channel that always offers the newest build. The platform keeps two builds of each channel apart,
as variants: release, the properly signed build everyone uses, and debug, for testers and
developers. The page offers both when both exist, the regular build first.
The pipeline publishes each build with the application’s service account:
fcdev updates binaries publish android/app/build/outputs/apk/release/app-release.apk \ --message "1.4.0" --commit "$GIT_SHA" --profile prodfcdev updates binaries publish android/app/build/outputs/apk/debug/app-debug.apk --profile prodThe command reads the APK: its package, version, runtime version and signing certificate, and the
application, app key and channel its update URL and expo-channel-name name. --app, --app-key,
--channel and --variant override what it reads. It refuses a file that is not a signed APK (v2 or
v3 signature), and a release build that is debuggable or signed with the Android debug keystore
(that key is public; sign release builds with the app’s own key). It uploads the file once and
publishes it; publishing the same file again changes nothing.
fcdev updates binaries inspect <apk>shows what it reads, without a platform.fcdev updates binaries list --app acmeshows what is published;NEWESTmarks what an install link gives.
An operator makes the link (role App Update Administrator; an application’s service account cannot):
fcdev updates links create --app acme --app-key driver-app --channel production --profile prod# https://platform.example.com/app-updates/acme/driver-app/install/3q2-… (shown once)The address carries a token the platform keeps only as a hash, so it is printed once. Anyone holding the address can download the builds, so send it only to the people who need it.
| Command | Effect |
|---|---|
fcdev updates links replace <linkId> |
The old address stops working at once and the command prints the new one. |
fcdev updates links remove <linkId> |
Takes the link away; its address stops working at once. |
fcdev updates links list --app acme |
Lists the links (never their addresses). |
A person opening the link sees a page with the app’s name, each build with its version, date and size and a download button, the steps to install an APK on Android, and a QR code of the page. A link that was replaced or removed shows “This link does not work”. Every binary published and every link created, replaced or removed is in the audit log.
Keep updates and binaries in step
Section titled “Keep updates and binaries in step”An update is for the binaries of one runtime version. fcdev updates binaries has --app acme --app-key driver-app --channel production --runtime-version "$RV" exits 0 when a binary of that runtime version
is published on the channel, 1 when none is and 2 when the question failed, for a script to branch on.
fcdev updates publish warns when an Android update’s runtime version has no binary on its channel,
and --require-binary refuses to publish it instead. Use that when every phone of the channel is
installed from this platform; iOS binaries are not published here.
Trying it locally
Section titled “Trying it locally”fcdev start creates a development signing key (key id main) and serves the same routes.
fcdev updates certificate > certificate.pem prints the certificate for a development build. An
Android emulator reaches the host’s fcdev at http://10.0.2.2:<port>, so a development build’s
update URL is http://10.0.2.2:8080/app-updates/<application>/<app key>/manifest (an http:// URL
needs cleartext traffic allowed in the development build). Publish with fcdev updates publish
against the local fcdev, as above without --profile.