Updates.reloadFromCache

I have the following code, taken from the example in Updates documentation.

const update = await Updates.checkForUpdateAsync();

if (update.isAvailable) {
await Updates.fetchUpdateAsync();
Updates.reloadFromCache();
}

Problem is that Updates.reloadFromCache() works as expected on iOS but doesn’t work on Android. Thus, I can’t force an update on Android in the code. Please help.

1 Like

Hey @gradientbv!

When you say it doesn’t work as expected on Android, what exactly happens in your app? Also, let me know what SDK version you’re using.

Thanks!

Same thing happened on SDK 29 and now in 32. After the code above is executed, android app simply continues (Updates.reloadFromCache(); is ignored) and I’m starting to use the version of the app I used right before. Whereas on iOS it is restarting and I’m using the latest version (the one that was just downloaded).

@gradientbv

Is this running on a simulator or on a device?

On a device.

UPD: it was installed using apk generated with expo build:android. Phone: Pixel 3.
And here is the full code snippet:

async _checkForUpdate() {
  try {
    const update = await Updates.checkForUpdateAsync();

    if (update.isAvailable) {
      await Updates.fetchUpdateAsync();
      Updates.reloadFromCache();
    }
  } catch (e) {}
}

render() {
...
  if (!this._appIsReady()) {
    return (
      <AppLoading
        startAsync={() => this._checkForUpdate().then(() => this.initApplication())}
        onFinish={() => this.setState({ assetsReady: true })}
        onError={console.warn}
      />
    );
...
  }

Thanks for sharing that, are you certain that update.isAvailable evaluates to true?

As that seems the most likely case for Updates.reloadFromCache(); to be missed.

Hey there. I’m also having this issue on Android. The app just re-renders, but it does not reload (it does not restart). And I am sure that update.isAvailable evaluated to true.

I am using SDK version 31; running on an HTC One M8.

Is there another way to trigger a restart of the application?

1 Like

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