Skip to content

Commit

Permalink
Fixes #134
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Mar 29, 2018
1 parent 7a08bbe commit 705c94f
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs
Expand Up @@ -16,6 +16,8 @@ namespace Plugin.InAppBilling
[Preserve(AllMembers = true)]
public class InAppBillingImplementation : BaseInAppBilling
{
static bool IsiOS112 => UIDevice.CurrentDevice.CheckSystemVersion(11, 2);

/// <summary>
/// Gets or sets a callback for out of band purchases to complete.
/// </summary>
Expand Down Expand Up @@ -64,8 +66,8 @@ public async override Task<IEnumerable<InAppBillingProduct>> 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
});
}

Expand Down Expand Up @@ -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);


/// <remarks>
/// Use Apple's sample code for formatting a SKProduct price
Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit 705c94f

Please sign in to comment.