Merge pull request #1073 from dluksza/notification-schedule-classcastexception

Fix ClassCastException while parsing fireDate
This commit is contained in:
Chris Bianca 2018-05-11 14:26:46 +01:00 committed by GitHub
commit 6848044f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 9 deletions

View File

@ -309,9 +309,12 @@ public class RNFirebaseNotificationManager {
// 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);
} catch (ClassCastException e) {
fireDate = schedule.getLong("fireDate", -1);
}
if (fireDate == -1) {
if (promise == null) {
Log.e(TAG, "Missing schedule information");
@ -320,7 +323,6 @@ public class RNFirebaseNotificationManager {
}
return;
}
}
// Scheduled alarms are cleared on restart
// We store them so that they can be re-scheduled when the phone restarts in RNFirebaseNotificationsRebootReceiver