Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Jul 23, 2020
1 parent ffb0288 commit aebdb19
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Plugin.InAppBilling/InAppBilling.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Java.Lang;
using System.Text;
using Android.BillingClient.Api;
using Android.Content;

[assembly: UsesPermission("com.android.vending.BILLING")]
namespace Plugin.InAppBilling
Expand All @@ -23,8 +24,10 @@ public class InAppBillingImplementation : BaseInAppBilling
/// This is set from the MainApplication.cs file that was laid down by the plugin
/// </summary>
/// <value>The context.</value>
Activity Context =>
Xamarin.Essentials.Platform.CurrentActivity ?? throw new NullReferenceException("Current Context/Activity is null, ensure that the MainActivity.cs file is configuring Xamarin.Essentials in your source code so the In App Billing can use it.");
Activity Activity =>
Xamarin.Essentials.Platform.CurrentActivity ?? throw new NullReferenceException("Current Activity is null, ensure that the MainActivity.cs file is configuring Xamarin.Essentials in your source code so the In App Billing can use it.");

Context Context => Android.App.Application.Context;

/// <summary>
/// Default Constructor for In App Billing Implemenation on Android
Expand Down Expand Up @@ -238,7 +241,7 @@ async Task<InAppBillingPurchase> PurchaseAsync(string productSku, string itemTyp
.Build();

tcsPurchase = new TaskCompletionSource<(BillingResult billingResult, IList<Android.BillingClient.Api.Purchase> purchases)>();
var responseCode = BillingClient.LaunchBillingFlow(Context, flowParams);
var responseCode = BillingClient.LaunchBillingFlow(Activity, flowParams);
ParseBillingResult(responseCode);

var result = await tcsPurchase.Task;
Expand Down

0 comments on commit aebdb19

Please sign in to comment.