Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startUpdate error: Error: Update type unavailable, check checkNeedsUpdate.isImmediateUpdateAllowed or checkNeedsUpdate.isFlexibleUpdateAllowed first. #127

Open
JameDodgers opened this issue Feb 3, 2023 · 3 comments

Comments

@JameDodgers
Copy link

Hello, thank you for your work in this library.

I recently started to use it and I'm receiving this error in Sentry, which made me think if the code in docs and example project shouldn't be changed to something like that:

inAppUpdates.checkNeedsUpdate().then((result) => {
  if (result.shouldUpdate) {
    let updateOptions = {};
    if (Platform.OS === 'android') {
      if (result.isFlexibleUpdateAllowed) {
        updateOptions = {
          updateType: IAUUpdateKind.FLEXIBLE,
        };
        inAppUpdates.startUpdate(updateOptions);
      }
    } else {
      inAppUpdates.startUpdate(updateOptions);
    }
  }
});
@SudoPlz
Copy link
Owner

SudoPlz commented Feb 3, 2023

Hey there.

If flexible is not allowed, that's probably because updating is not allowed in general (for various reasons) - since flexible seems like the default way of handling updates and there aren't any other fallbacks.
I don't know if it makes sense to stop the error that would show up upon startUpdate by checking isFlexibleUpdateAllowed, that's why it wasn't mentioned in the docs.

@JameDodgers
Copy link
Author

JameDodgers commented Feb 4, 2023

Thanks for your quick response.

As you mentioned, as this library is just a wrapper around Google In App Updates API, throwing this error shouldn't be part of the normal usage flow in my understanding. If I previously know that the update it's not allowed, why call startUpdate and throw an error that could be avoided?

@frzkn
Copy link

frzkn commented Jul 3, 2023

#151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants