Skip to content

Commit

Permalink
Merge pull request #1073 from dluksza/notification-schedule-classcast…
Browse files Browse the repository at this point in the history
…exception

Fix ClassCastException while parsing fireDate
  • Loading branch information
chrisbianca authored May 11, 2018
2 parents 13dd662 + dbc5a2d commit 6848044
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,19 @@ private void scheduleNotification(Bundle notification, @Nullable Promise promise
// fireDate is stored in the Bundle as Long after notifications are rescheduled.
// This would lead to a fireDate of 0.0 when trying to extract a Double from the bundle.
// Instead always try extract a Long
Long fireDate = schedule.getLong("fireDate", -1);
if (fireDate == -1) {
Long fireDate = -1L;
try {
fireDate = (long) schedule.getDouble("fireDate", -1);
if (fireDate == -1) {
if (promise == null) {
Log.e(TAG, "Missing schedule information");
} else {
promise.reject("notification/schedule_notification_error", "Missing fireDate information");
}
return;
} catch (ClassCastException e) {
fireDate = schedule.getLong("fireDate", -1);
}
if (fireDate == -1) {
if (promise == null) {
Log.e(TAG, "Missing schedule information");
} else {
promise.reject("notification/schedule_notification_error", "Missing fireDate information");
}
return;
}

// Scheduled alarms are cleared on restart
Expand Down

0 comments on commit 6848044

Please sign in to comment.