From 705c94f72970f70ab443987dc53fa6b9cf4b3a24 Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Thu, 29 Mar 2018 08:13:44 -0700 Subject: [PATCH] Fixes #134 --- .../InAppBillingImplementation.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs b/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs index b0e892a..7b83ae8 100644 --- a/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs +++ b/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs @@ -16,6 +16,8 @@ namespace Plugin.InAppBilling [Preserve(AllMembers = true)] public class InAppBillingImplementation : BaseInAppBilling { + static bool IsiOS112 => UIDevice.CurrentDevice.CheckSystemVersion(11, 2); + /// /// Gets or sets a callback for out of band purchases to complete. /// @@ -64,8 +66,8 @@ public async override Task> GetProductInfoAsync ProductId = p.ProductIdentifier, Description = p.LocalizedDescription, CurrencyCode = p.PriceLocale?.CurrencyCode ?? string.Empty, - LocalizedIntroductoryPrice = p.IntroductoryPrice.CanBeUsed() ? p.IntroductoryPrice.LocalizedPrice() : "", - MicrosIntroductoryPrice = p.IntroductoryPrice.CanBeUsed() ? (long)(p.IntroductoryPrice.Price.DoubleValue * 1000000d) : 0 + LocalizedIntroductoryPrice = IsiOS112 ? p.IntroductoryPrice.LocalizedPrice() : string.Empty, + MicrosIntroductoryPrice = IsiOS112 ? (long)(p.IntroductoryPrice.Price.DoubleValue * 1000000d) : 0 }); } @@ -517,7 +519,7 @@ public static PurchaseState GetPurchaseState(this SKPaymentTransaction transacti [Preserve(AllMembers = true)] static class SKProductExtension { - static bool IsiOS112 => UIDevice.CurrentDevice.CheckSystemVersion(11, 2); + /// /// Use Apple's sample code for formatting a SKProduct price @@ -552,10 +554,5 @@ public static string LocalizedPrice(this SKProduct product) Console.WriteLine(" ** formatter.StringFromNumber(" + product.Price + ") = " + formattedString + " for locale " + product.PriceLocale.LocaleIdentifier); return formattedString; } - - public static bool CanBeUsed(this SKProductDiscount product) - { - return IsiOS112 && product != null; - } } }