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 double call of result reply on connection init #126

Merged
merged 1 commit into from
Nov 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ else if (call.method.equals("initConnection")) {
.enablePendingPurchases()
.build();
billingClient.startConnection(new BillingClientStateListener() {
private boolean alreadyFinished = false;

@Override
public void onBillingSetupFinished(BillingResult billingResult) {
try {
Expand All @@ -81,11 +83,15 @@ public void onBillingSetupFinished(BillingResult billingResult) {
JSONObject item = new JSONObject();
item.put("connected", true);
channel.invokeMethod("connection-updated", item.toString());
if (alreadyFinished) return;
alreadyFinished = true;
result.success("Billing client ready");
} else {
JSONObject item = new JSONObject();
item.put("connected", false);
channel.invokeMethod("connection-updated", item.toString());
if (alreadyFinished) return;
alreadyFinished = true;
result.error(call.method, "responseCode: " + responseCode, "");
}
} catch (JSONException je) {
Expand Down