From 66ff66d58aa2f6f6518b0c3bf0dc66c886ad0e8d Mon Sep 17 00:00:00 2001 From: Cesar de la Vega Date: Tue, 6 Nov 2018 12:32:35 -0800 Subject: [PATCH] fixes compile issue with Android --- .../java/com/reactlibrary/RNPurchasesModule.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/reactlibrary/RNPurchasesModule.java b/android/src/main/java/com/reactlibrary/RNPurchasesModule.java index 6eb1bc63..a547f38e 100644 --- a/android/src/main/java/com/reactlibrary/RNPurchasesModule.java +++ b/android/src/main/java/com/reactlibrary/RNPurchasesModule.java @@ -70,7 +70,7 @@ public void setupPurchases(String apiKey, String appUserID, final Promise promis purchases = new Purchases.Builder(reactContext, apiKey, this).appUserID(appUserID).build(); promise.resolve(null); } - + @ReactMethod public void setIsUsingAnonymousID(boolean isUsingAnonymousID) { checkPurchases(); @@ -95,14 +95,18 @@ private WritableMap mapForSkuDetails(final SkuDetails detail) { map.putString("title", detail.getTitle()); map.putDouble("price", detail.getPriceAmountMicros() / 1000000d); map.putString("price_string", detail.getPrice()); - - map.putString("intro_price", detail.getIntroductoryPriceAmountMicros() / 1000000d); + String introductoryPriceAmountMicros = detail.getIntroductoryPriceAmountMicros(); + if (introductoryPriceAmountMicros != null && !introductoryPriceAmountMicros.isEmpty()) { + map.putString("intro_price", String.valueOf(Long.parseLong(introductoryPriceAmountMicros) / 1000000d)); + } else { + map.putString("intro_price", ""); + } map.putString("intro_price_string", detail.getIntroductoryPrice()); map.putString("intro_price_period", detail.getIntroductoryPricePeriod()); map.putString("intro_price_cycles", detail.getIntroductoryPriceCycles()); map.putString("currency_code", detail.getPriceCurrencyCode()); - + return map; } @@ -370,5 +374,5 @@ private static JSONArray convertArrayToJson(ReadableArray readableArray) throws } return array; } - + }