diff --git a/android/src/main/java/com/zoyi/channel/rn/ParseUtils.java b/android/src/main/java/com/zoyi/channel/rn/ParseUtils.java index c99620a..60d3145 100644 --- a/android/src/main/java/com/zoyi/channel/rn/ParseUtils.java +++ b/android/src/main/java/com/zoyi/channel/rn/ParseUtils.java @@ -113,7 +113,14 @@ public static Map toHashMap(ReadableMap readableMap) { break; case Number: - hashMap.put(key, Utils.getDouble(readableMap, key).getValue()); + try { + int number = readableMap.getInt(key); + hashMap.put(key, number); + } catch (Exception e) { + double number = readableMap.getDouble(key); + hashMap.put(key, number); + } + break; case String: @@ -380,16 +387,40 @@ public static UserData toUserData(ReadableMap userDataMap) { } public static Map toPushNotification(ReadableMap pushNotificationMap) { - Map pushNotification = new HashMap<>(); + HashMap pushNotification = new HashMap<>(); ReadableMapKeySetIterator iterator = pushNotificationMap.keySetIterator(); while (iterator.hasNextKey()) { String key = iterator.nextKey(); ReadableType type = pushNotificationMap.getType(key); - String value = pushNotificationMap.getString(key); - if (type == ReadableType.String && value != null) { - pushNotification.put(key, value); + switch (type) { + case Boolean: + boolean bool = pushNotificationMap.getBoolean(key); + pushNotification.put(key, Boolean.toString(bool)); + break; + + case Number: + try { + int number = pushNotificationMap.getInt(key); + pushNotification.put(key, Integer.toString(number)); + } catch (Exception e) { + double number = pushNotificationMap.getDouble(key); + pushNotification.put(key, Double.toString(number)); + } + + break; + + case String: + String str = pushNotificationMap.getString(key); + + if (str != null) { + pushNotification.put(key, str); + } + break; + + default: + break; } }