Updates.checkForUpdateAsync never returns

I’m not sure what is going wrong in your case. It could be that the app is having problems connecting to the server to check for, or download the updates. In case it helps, I’ve included below how I do it.

I’m not sure if this is the best way to do it, but I do it like this:

I keep track of the last time the app checked for an update in a tick variable. Then every time the user changes to a different screen I check if enough time has passed since the last check. If so, I set the tick variable to the current time.

I have a useEffect hook that depends on the tick variable, so when tick changes the effect is called.

  useEffect(() => {
    if (!__DEV__) {
      Updates.checkForUpdateAsync().then(({ isAvailable, manifest }) => {
        if (isAvailable) setUpdateAvailable(true);
      });
    }
  }, [tick]);

Then I have a button that I show if updateAvailable is true.

      <UpdateButton visible={updateAvailable} top={insets.top} />
const UpdateButton = props => {
  const { visible, top } = props;
  return (
    <FAB
      style={{
        position: "absolute",
        margin: 16,
        right: 0,
        top,
        backgroundColor: "#36454f"
      }}
      icon="cloud-download"
      label="Update"
      color="white"
      visible={visible}
      onPress={() => Updates.reload()}
    />
  );
};

This works for me.

1 Like