Skip to content

Commit

Permalink
[expo-notifications] Fix crash when null value is passed in data
Browse files Browse the repository at this point in the history
  • Loading branch information
sjchmiela committed May 5, 2020
1 parent 651a78d commit 0e7f591
Showing 1 changed file with 9 additions and 11 deletions.
Expand Up @@ -91,17 +91,15 @@ private static Bundle toBundle(@Nullable JSONObject notification) {
Iterator<String> keyIterator = notification.keys();
while (keyIterator.hasNext()) {
String key = keyIterator.next();
try {
Object value = notification.get(key);
if (value instanceof JSONObject) {
notificationMap.put(key, toBundle((JSONObject) value));
} else if (value instanceof JSONArray) {
notificationMap.put(key, toList((JSONArray) value));
} else if (value != null) {
notificationMap.put(key, value);
}
} catch (JSONException e) {
Log.e("expo-notifications", "Could not serialize whole notification - dropped value for key " + key + ": " + notification.opt(key));
Object value = notification.opt(key);
if (value instanceof JSONObject) {
notificationMap.put(key, toBundle((JSONObject) value));
} else if (value instanceof JSONArray) {
notificationMap.put(key, toList((JSONArray) value));
} else if (JSONObject.NULL.equals(value)) {
notificationMap.put(key, null);
} else {
notificationMap.put(key, value);
}
}
return new MapArguments(notificationMap).toBundle();
Expand Down

0 comments on commit 0e7f591

Please sign in to comment.