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

Commit 9d34e8e

Browse files
committed
Add nullchecks for JSON parsing
1 parent 82d7198 commit 9d34e8e

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
@@ -67,8 +67,10 @@ NotificationsComponent.prototype.addEventListener = function(type: string, handl
6767
listener = DeviceEventEmitter.addListener(
6868
DEVICE_NOTIF_EVENT,
6969
function(notifData) {
70-
var data = JSON.parse(notifData.dataJSON);
71-
handler(data);
70+
if (notifData && notifData.dataJSON) {
71+
var data = JSON.parse(notifData.dataJSON);
72+
handler(data);
73+
}
7274
}
7375
);
7476
} else if (type === 'register') {
@@ -82,8 +84,10 @@ NotificationsComponent.prototype.addEventListener = function(type: string, handl
8284
listener = DeviceEventEmitter.addListener(
8385
REMOTE_FETCH_EVENT,
8486
function(notifData) {
85-
var notificationData = JSON.parse(notifData.dataJSON)
86-
handler(notificationData);
87+
if (notifData && notifData.dataJSON) {
88+
var notificationData = JSON.parse(notifData.dataJSON)
89+
handler(notificationData);
90+
}
8791
}
8892
);
8993
}

0 commit comments

Comments
 (0)