From 4e79abc1bd63c0b61b9ab607305ea3f057b7b3e4 Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Mon, 2 Oct 2017 14:47:40 +0200 Subject: [PATCH] Check for null serviceConnection #80 --- .../InAppBillingImplementation.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs b/src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs index 935a842..e954199 100644 --- a/src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs +++ b/src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs @@ -73,7 +73,7 @@ public InAppBillingImplementation() /// public async override Task> GetProductInfoAsync(ItemType itemType, params string[] productIds) { - if (serviceConnection.Service == null) + if (serviceConnection?.Service == null) { throw new InAppBillingPurchaseException(PurchaseError.BillingUnavailable, "You are not connected to the Google Play App store."); } @@ -143,7 +143,7 @@ Task> GetProductInfoAsync(string[] productIds, string itemT /// The current purchases public async override Task> GetPurchasesAsync(ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null) { - if (serviceConnection.Service == null) + if (serviceConnection?.Service == null) { throw new InAppBillingPurchaseException(PurchaseError.BillingUnavailable, "You are not connected to the Google Play App store."); } @@ -244,7 +244,7 @@ public async override Task PurchaseAsync(string productId, throw new ArgumentNullException(nameof(payload), "Payload can not be null"); - if (serviceConnection.Service == null) + if (serviceConnection?.Service == null) { throw new InAppBillingPurchaseException(PurchaseError.BillingUnavailable, "You are not connected to the Google Play App store."); } @@ -395,7 +395,7 @@ public async override Task DisconnectAsync() /// If consumed successful public override Task ConsumePurchaseAsync(string productId, string purchaseToken) { - if (serviceConnection.Service == null) + if (serviceConnection?.Service == null) { throw new InAppBillingPurchaseException(PurchaseError.BillingUnavailable, "You are not connected to the Google Play App store."); } @@ -459,7 +459,7 @@ bool ParseConsumeResult(int response) /// If consumed successful public async override Task ConsumePurchaseAsync(string productId, ItemType itemType, string payload, IInAppBillingVerifyPurchase verifyPurchase) { - if (serviceConnection.Service == null) + if (serviceConnection?.Service == null) throw new InAppBillingPurchaseException(PurchaseError.BillingUnavailable, "You are not connected to the Google Play App store.");