Skip to content

Commit

Permalink
Merge pull request #379 from dajaffe/master
Browse files Browse the repository at this point in the history
Fix for BillingClientImpl Crashes - Promise consumed twice
  • Loading branch information
hyochan authored Jan 25, 2019
2 parents 4163d77 + 1027aa3 commit e4192c7
Showing 1 changed file with 6 additions and 1 deletion.
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;
callback.run();
}
} else {
rejectPromiseWithBillingError(promise, responseCode);
}
Expand Down

0 comments on commit e4192c7

Please sign in to comment.