Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit d7705f8

Browse files
authored
Merge pull request #586 from Pootsy/master
Add nullchecks for JSON parsing
2 parents e3a5a81 + 9d34e8e commit d7705f8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

component/index.android.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ NotificationsComponent.prototype.addEventListener = function(type, handler) {
7575
listener = DeviceEventEmitter.addListener(
7676
DEVICE_NOTIF_EVENT,
7777
function(notifData) {
78-
var data = JSON.parse(notifData.dataJSON);
79-
handler(data);
78+
if (notifData && notifData.dataJSON) {
79+
var data = JSON.parse(notifData.dataJSON);
80+
handler(data);
81+
}
8082
}
8183
);
8284
} else if (type === 'register') {
@@ -90,8 +92,10 @@ NotificationsComponent.prototype.addEventListener = function(type, handler) {
9092
listener = DeviceEventEmitter.addListener(
9193
REMOTE_FETCH_EVENT,
9294
function(notifData) {
93-
var notificationData = JSON.parse(notifData.dataJSON)
94-
handler(notificationData);
95+
if (notifData && notifData.dataJSON) {
96+
var notificationData = JSON.parse(notifData.dataJSON)
97+
handler(notificationData);
98+
}
9599
}
96100
);
97101
}

0 commit comments

Comments
 (0)