Closed codlab closed 2 years ago
Hi @codlab, First thing I can see (and that is most likely the cause of your issue) is that you're not using the correct version of react-native-iap as a dependency. You must use the version 5.2.6 (https://github.com/iaphub/react-native-iaphub#getting-started).
I will fork to make this lib coherent with the required updates of the underlying libraries as well as the possible requirements from the stores in the future. Staying at 2 major versions can't be a solution here
There is no need @codlab, we're already working on a major new release that won't use react-native-iap as a dependency
I'm seeing an issue which seems to be concerning react-native-iap but impacting negatively the implementation of the react-native-iaphub library. To reproduce, I'm using those versions:
To reproduce the issue (I removed some part):
Using this code and cancelling the purchase (by tapping outside of the PlayStore's popup), the promise is rejecting however set as unhandled
When I was investigating in the library implementation, I noticed that the buy method is doing the following:
and adding breakpoints to the logic, when calling this buy method, it wouldn't return the buyPromise (as expected due to the async paradigm) and even by tapping outside of the method, cancelling the action, it wasn't returning. Which meant that the RNIap method is actually not resolving/rejecting by itself (regression on their end?)
Since the buyPromise is returned and will be rejected/resolved asynchronously, I could "fix" (well... quite tacky for sure) by moving the async try/catch block into an async method which gets called without locking the event loop ; the buyPromise is returned and is rejecting as a result without the unhandled issue since it's properly registered in the native manager
The modified implementation then looks like this:
edit: I'm not opening an issue in the react-native-iap project right now due to schedule issue. If anyone as a comment or remark about this report or any question, please feel free to comment and if I can help, I'll do