How to Support Over-the-Air Updates on Multiple Expo SDKs in Parallel

One thing to keep in mind when updating Expo SDKs

Wiktor Malinowski
Sep 27 · 4 min read
Image for post
Image for post
Photo by Kit Suman on Unsplash

Expo is fantastic. It helps you develop, build, and deploy iOS, Android, and web apps — from the same code base.

It builds the binaries for both Android and iOS on its servers and provides support for the release channels and the over-the-air (OTA) updates.

OTA Updates

The OTA updates work for any published changes to the JS bundle. You add the new feature to the app, run the Expo build, and publish. And that’s it. Users get the update right away on their devices — in the background and without updating the native app. Everything looks great so far!

Upgrading the Expo SDK

When you decide to upgrade the Expo SDK, there’s one thing you must remember: The SDK upgrade requires the native app to be updated on the application store (App Store, Google Play).

To get the new bundle via an OTA update, the SDK on the installed app must match the published one. But there’s no guarantee all users install updates immediately. And that’s the thing.

This is the flowchart that describes how the Expo determines which release to return to a user:

Image for post
Image for post
Illustration via the Expo docs

You can find more details about the publishing process here.

The case is that the native app built with the older SDK won’t receive any OTA updates for any subsequent SDK release until the user updates the native app.

Yeah, I understand. You might just want to communicate that the user should update the app — deploy a subtle “Please update the app” banner on the old version and forget about the thing.

Fair enough. That’s OK for most cases.

Deep down, though, you may realize that what you really want is to be able to release any security and stability patches for the old versions as well. You may also want the ability to add some urgent feature that displays the CTA button for the new service you added, let’s say, because of the pandemic.

The Approach

You can just assume you’ll only support the latest version.

I’d suggest you check the application statistics. Specify the percentage threshold of the users you want to cover with updates. Based on that, define the exact SDK versions you have to support.

Repository

Create a branch from main, right before the SDK upgrade. If it’s too late, use the last commit before the upgrade.

For example, $ git switch main; git switch -c main-expo-sdk-36.

Merge any feature branch to main as usual. Additionally, apply the feature to the other SDK branch as well. Assume you want to merge the CTA button feature from the feature/cta-button branch.

(main) $ git merge feature/cta-button
(main) $ git push
(main) $ git switch main-expo-sdk36
(main-expo-sdk-36) $ git merge feature/cta-button
(main-expo-sdk-36) $ git push

Deployment

The process remains unchanged, except that you have to do the same also for every main-expo-sdk-* branch. It can be deployed to the same release channel (see the diagram above).

Local development

Using the same source folder is time-consuming.

You have to reinstall node modules when switching between the SDK versions. This can be a pain if you want to perform several updates.

The solution is to create multiple project instances, one for each version of the SDK you’ll support. This is explained in the next section.

Clone the repo to a different folder(s), and work on the main-expo-sdk-* branches there. Assume you have a my-app app, and you want to support SDK 36.

# clone the same repository to my-app-sdk-36
$ git clone git@server:my-app.git ~/repos/my-app-sdk-36;
# it should be a new folder here
$ ls ~/repos;
my-app
my-app-expo-sdk-36
# enter the new folder and switch the branch to the SDK
$ cd my-app-expo-36;
$ git switch main-expo-sdk-36;

Summary

This the solution to reach most of the users with urgent updates.

When you upgrade the Expo SDK that doesn’t mean every device got the update right away. The subsequent OTA updates wono’t work for the devices with older SDKs.

This is OK for most cases, but now you’re prepared for other scenarios as well.

Better Programming

Advice for programmers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store