OTA Update over Wifi Only

Using the default Expo SDK 34 settings for OTA Updates, is there an automated way to force the app to download OTA updates over Wifi only and not over Cellular?

Additionally, are the OTA updates for the entire build binary, or just the difference/delta between the previous build and the newest build?

Hey @nyxynyx,

Yes, this possible to a degree (thought not quite as strictly as you may hope). You will want to update your updates field in app.json to have checkAutomatically: "ON_ERROR_RECOVERY" and then you can leverage the NetInfo API to determine the current netInfoStateType and only call the following when it is equal to wifi.

try {
  const update = await Expo.Updates.checkForUpdateAsync();
  if (update.isAvailable) {
    await Expo.Updates.fetchUpdateAsync();
    // ... notify user of update ...
    Expo.Updates.reloadFromCache();
  }
} catch (e) {
  // handle or log error
}

Cheers,
Adam

1 Like

@adamjnav, please correct me if I’m wrong. I believe it works something like this:

For a managed app, as long as the installed version and the new version were built using the same Expo SDK version, OTA updates should work. What happens is that all the native code stays the same, but the whole JavaScript bundle will be transferred. The next time the app is started, this new JS bundle will be used.

For unmanaged apps it’s basically the same, except that additionally, the new version of the app needs to make sure not to make use of any new native modules. So e.g. if you install one version of the app on your phone and then later run:

yarn install react-native-something
react-native link react-native-something

and then make use of this in the JS, you will not be able to do a successful OTA update, because the native code already installed on the device does not include react-native-something.

So this is somewhere between a full install and a differential install. It’s not a full install (as long as the same SDK was used), but the whole JS bundle is transferred.

1 Like

That’s pretty much correct. Just want to make a further clarification that “Unmanaged” can only mean ExpoKit projects currently. Bare workflow projects can not make use of Updates yet, but we’re getting close to having support for it!

OTA updates only picks up JS differences and asset changes. Making changes on the native level, such as many of the configurations found in your app.json require building a new binary and submitting to the app store. You can read more about expo publish limitations here.

Cheers,
Adam

1 Like

Thank you all!

Is there a way to know the file size of the OTA update that will be downloaded by the managed Expo app?

you can find the link to the S3 file in the log after you publish - mine is ~35k lines of code, I’d say I’m using an average number of libraries and it ends up being ~5MB per bundle.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.