Closed fabian-meisinger closed 3 months ago
I have noticed the exact same problem today. If the user is not logged in into the Google Playstore, the following error is thrown: "Init failed - Setup failed. BILLING_UNAVAILABLE: Google Play In-app Billing API version is less than 3" but the the initialize function never resolves:
await CdvPurchase.store.initialize([platform]);
I encountered the same error, but it is now resolved after log-in into the Google Play Store and updating it on the emulator.
Observed behavior
Errors within the store.initialize function on Android never resolve or reject the returned Promise (e.g. when using an emulator without a logged in account). The error also does not get logged when debug logging is active and only is shown when a listener is registered via store.error.
Internally the iabError function also calls initialize again, which writes to the log and then immediately exits, because the
initializationPromise
is still set.In addition when store.initialize is called again after the first failed attempt (e.g. after a hot reload), it succeeds because the
initializedHasBeenCalled
flag is already set to true, even though the store is not really initialized.Expected behavior
The initialize function should reject the promise and pass the error. On subsequent calls it should also return the original Promise in case initialization is still in progress.
I also didn't notice the store.error listener until after I debugged the problem, because I expected all listeners to be available on store.when(), so maybe you could add an alias there for better consistency.
System Info