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

Fix for BillingClientImpl Crashes - Promise consumed twice #379

Merged
merged 2 commits into from
Jan 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion android/src/main/java/com/dooboolab/RNIap/RNIapModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,16 @@ private void ensureConnection (final Promise promise, final Runnable callback) {
intent.setPackage("com.android.vending");

final BillingClientStateListener billingClientStateListener = new BillingClientStateListener() {
private boolean bSetupCallbackConsumed = false;

@Override
public void onBillingSetupFinished(@BillingClient.BillingResponse int responseCode) {
if (responseCode == BillingClient.BillingResponse.OK ) {
Log.d(TAG, "billing client ready");
callback.run();
if (!bSetupCallbackConsumed) {
bSetupCallbackConsumed = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope you to review the PR in #359 and check if this is really fixing the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the mBillingClient null check and isReady just moved the crash happening a little later. With 359's PR, that fixed where the old billing client was destroyed from the disconnect, but still attempted to be used. With that fix in place, it moved from trying to use an old client, to using a new one, but trying to hit the old promise a second time.

callback.run();
}
} else {
rejectPromiseWithBillingError(promise, responseCode);
}
Expand Down