Skip to content
30 changes: 20 additions & 10 deletions source/com.android.billingclient/billing/Additions/Additions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void SetListener(Action<BillingResult, IList<Purchase>> handler)
}
}

public Task<BillingResult> AcknowledgePurchaseAsync(AcknowledgePurchaseParams acknowledgePurchaseParams)
public async Task<BillingResult> AcknowledgePurchaseAsync(AcknowledgePurchaseParams acknowledgePurchaseParams)
{
var tcs = new TaskCompletionSource<BillingResult>();

Expand All @@ -76,10 +76,12 @@ public Task<BillingResult> AcknowledgePurchaseAsync(AcknowledgePurchaseParams ac

AcknowledgePurchase(acknowledgePurchaseParams, listener);

return tcs.Task;
var result = await tcs.Task;
GC.KeepAlive(listener);
return result;
}

public Task<ConsumeResult> ConsumeAsync(ConsumeParams consumeParams)
public async Task<ConsumeResult> ConsumeAsync(ConsumeParams consumeParams)
{
var tcs = new TaskCompletionSource<ConsumeResult>();

Expand All @@ -94,7 +96,9 @@ public Task<ConsumeResult> ConsumeAsync(ConsumeParams consumeParams)

Consume(consumeParams, listener);

return tcs.Task;
var result = await tcs.Task;
GC.KeepAlive(listener);
return result;
}

const string QueryPurchaseHistoryNotSupported = "QueryPurchaseHistory method was removed in Billing Client v8.0.0. Use QueryPurchasesAsync instead. See: https://developer.android.com/google/play/billing/migrate";
Expand Down Expand Up @@ -125,7 +129,7 @@ public Task<QuerySkuDetailsResult> QuerySkuDetailsAsync(SkuDetailsParams skuDeta
throw new NotSupportedException(QuerySkuDetailsNotSupported);
}

public Task<QueryProductDetailsResult> QueryProductDetailsAsync(QueryProductDetailsParams productDetailsParams)
public async Task<QueryProductDetailsResult> QueryProductDetailsAsync(QueryProductDetailsParams productDetailsParams)
{
var tcs = new TaskCompletionSource<QueryProductDetailsResult>();

Expand All @@ -136,10 +140,12 @@ public Task<QueryProductDetailsResult> QueryProductDetailsAsync(QueryProductDeta

QueryProductDetails(productDetailsParams, listener);

return tcs.Task;
var result = await tcs.Task;
GC.KeepAlive(listener);
return result;
Copy link
Member

Choose a reason for hiding this comment

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

@tipa I think this is plausible that it could fix the ObjectDisposedException, but it seems like the old version would have had a similar issue.

The version number is unchanged, because we didn't ship it yet:

Copy link

Choose a reason for hiding this comment

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

@jonathanpeppers the problem persists - I will send you an example project for you to reproruce the crash

}

public Task<QueryPurchasesResult> QueryPurchasesAsync(QueryPurchasesParams purchasesParams)
public async Task<QueryPurchasesResult> QueryPurchasesAsync(QueryPurchasesParams purchasesParams)
{
var tcs = new TaskCompletionSource<QueryPurchasesResult>();

Expand All @@ -154,10 +160,12 @@ public Task<QueryPurchasesResult> QueryPurchasesAsync(QueryPurchasesParams purch

QueryPurchases(purchasesParams, listener);

return tcs.Task;
var result = await tcs.Task;
GC.KeepAlive(listener);
return result;
}

public Task<BillingResult> StartConnectionAsync(Action onDisconnected = null)
public async Task<BillingResult> StartConnectionAsync(Action onDisconnected = null)
{
var tcs = new TaskCompletionSource<BillingResult>();

Expand All @@ -174,7 +182,9 @@ public Task<BillingResult> StartConnectionAsync(Action onDisconnected = null)

StartConnection(listener);

return tcs.Task;
var result = await tcs.Task;
GC.KeepAlive(listener);
return result;
}

public void StartConnection(Action<BillingResult> setupFinished, Action onDisconnected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,12 @@ Android.BillingClient.Api.QueryProductDetailsParams.Product.Zza() -> string!
Android.BillingClient.Api.QueryProductDetailsParams.Product.Zzb() -> string!
Android.BillingClient.Api.QueryProductDetailsParams.Zzb() -> string!
Android.BillingClient.Api.QueryProductDetailsResult
Android.BillingClient.Api.QueryProductDetailsResult.ProductDetails.get -> System.Collections.Generic.IList<Android.BillingClient.Api.ProductDetails!>!
Android.BillingClient.Api.QueryProductDetailsResult.ProductDetails.set -> void
Android.BillingClient.Api.QueryProductDetailsResult.ProductDetailsList.get -> System.Collections.Generic.IList<Android.BillingClient.Api.ProductDetails!>!
Android.BillingClient.Api.QueryProductDetailsResult.QueryProductDetailsResult() -> void
Android.BillingClient.Api.QueryProductDetailsResult.Result.get -> Android.BillingClient.Api.BillingResult!
Android.BillingClient.Api.QueryProductDetailsResult.Result.set -> void
Android.BillingClient.Api.QueryProductDetailsResult.UnfetchedProductList.get -> System.Collections.Generic.IList<Android.BillingClient.Api.UnfetchedProduct!>!
Android.BillingClient.Api.QueryPurchaseHistoryParams
Android.BillingClient.Api.QueryPurchaseHistoryParams.Builder
Expand Down