(resolved) checkForUpdatesAsync seems to always return true

#1

Hello! I have a button in my app that checks for updates:

      const updateAvailable = await Updates.checkForUpdateAsync();
      if (updateAvailable) {
        await Updates.fetchUpdateAsync();
        Toast.show({
          textStyle: { fontFamily: 'Roboto_regular' },
          text: 'Update Available.',
          buttonText: 'OK',
          type: 'success',
        });
      }

I deployed the app as a standalone and every time I call this code it returns true that an update is available. Am I doing something wrong?

#2

My bad, I didn’t read the return type and due to lack of ability to test this on a simulator I didn’t realize. checkForUpdatesAsync returns an object with an isAvailable boolean prop.

      const { isAvailable } = await Updates.checkForUpdateAsync();
      if (isAvailable) {
        await Updates.fetchUpdateAsync();
        Toast.show({
          textStyle: { fontFamily: 'Roboto_regular' },
          text: 'Update Available.',
          buttonText: 'OK',
          type: 'success',
        });
      }
closed #3

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