expo-updates not updating internal distribution

381 views Asked by At

Trying to implement expo-updates and I'm a bit stumped. I have a deployment, channel and branch all called "testing". I have a good internal distribution build for both OSes, and can verify that the app configuration has updates.url. I have a successfully run eas update --channel testing, which shows up in the UI under "updates" and linked to the "testing" branch & channel.

I've force-quit the app a dozen times and still do not see the update. Do I have to implement something in the codebase for this to "take", or does Expo handle this automatically?

eas.json parts:

{
  ...
  "build": {
    "testing": {
      "channel": "testing",
      "distribution": "internal",
    },
    ...
  },
  ...
}

Expo Build output parts:

{
  "runtimeVersion": {
    "policy": "sdkVersion"
  },
  "updates": {
    "url": "https://u.expo.dev/<projectId>"
  },
  ...
}
1

There are 1 answers

0
orbiteleven On BEST ANSWER

I ended up having to do something like this to get updates to work:

  useEffect(() => {
    if (!__DEV__) {
      async function checkForUpdates() {
        let update: Updates.UpdateCheckResult;
        try {
          update = await Updates.checkForUpdateAsync();
        } catch (e) {
          throw new Error('Error checking for updates', e);
        }
        if (update.isAvailable) {
          setLoading(true);
          try {
            const fetchResult = await Updates.fetchUpdateAsync();
            setIsNew(fetchResult.isNew);
          } catch (e) {
            setLoading(false);
            throw new Error('Error fetching updates', e);
          }

          try {
            await Updates.reloadAsync();
          } catch (e) {
            setLoading(false);
            throw new Error('Error reloading app', e);
          }
          setLoading(false);
        }
      }
      checkForUpdates();
    }
  }, []);