From cc9ad1e20bbd57fe0217a28a484256d3cdb3e17d Mon Sep 17 00:00:00 2001 From: David Date: Wed, 23 Jan 2019 22:34:38 -0600 Subject: [PATCH 1/2] Experimental fix for double callback consume crash --- android/src/main/java/com/dooboolab/RNIap/RNIapModule.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/dooboolab/RNIap/RNIapModule.java b/android/src/main/java/com/dooboolab/RNIap/RNIapModule.java index 902652c90..04ecc5e72 100644 --- a/android/src/main/java/com/dooboolab/RNIap/RNIapModule.java +++ b/android/src/main/java/com/dooboolab/RNIap/RNIapModule.java @@ -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); } From 1027aa3d1a5ca5fee7196d8b30a3173746755855 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 24 Jan 2019 08:04:27 -0600 Subject: [PATCH 2/2] Fix spacingf --- android/src/main/java/com/dooboolab/RNIap/RNIapModule.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/dooboolab/RNIap/RNIapModule.java b/android/src/main/java/com/dooboolab/RNIap/RNIapModule.java index 04ecc5e72..4a17ae6f6 100644 --- a/android/src/main/java/com/dooboolab/RNIap/RNIapModule.java +++ b/android/src/main/java/com/dooboolab/RNIap/RNIapModule.java @@ -124,10 +124,10 @@ private void ensureConnection (final Promise promise, final Runnable callback) { public void onBillingSetupFinished(@BillingClient.BillingResponse int responseCode) { if (responseCode == BillingClient.BillingResponse.OK ) { Log.d(TAG, "billing client ready"); - if (!bSetupCallbackConsumed) { - bSetupCallbackConsumed = true; + if (!bSetupCallbackConsumed) { + bSetupCallbackConsumed = true; callback.run(); - } + } } else { rejectPromiseWithBillingError(promise, responseCode); }