Skip to content

Commit

Permalink
Fixes #148 to test for null pricelocal
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed May 2, 2018
1 parent 17c1390 commit a1680f4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ static class SKProductExtension
/// </remarks>
public static string LocalizedPrice(this SKProduct product)
{
if (product?.PriceLocale == null)
return string.Empty;

var formatter = new NSNumberFormatter()
{
FormatterBehavior = NSNumberFormatterBehavior.Version_10_4,
Expand All @@ -544,8 +547,12 @@ public static string LocalizedPrice(this SKProduct product)
return formattedString;
}

public static string LocalizedPrice(this SKProductDiscount product) {
var formatter = new NSNumberFormatter() {
public static string LocalizedPrice(this SKProductDiscount product)
{
if (product?.PriceLocale == null)
return string.Empty;

var formatter = new NSNumberFormatter() {
FormatterBehavior = NSNumberFormatterBehavior.Version_10_4,
NumberStyle = NSNumberFormatterStyle.Currency,
Locale = product.PriceLocale
Expand Down

0 comments on commit a1680f4

Please sign in to comment.