Merge pull request #1035 from liamheneghan/fix-android-rescheduled-notification-firedate

Fix Android rescheduled notifications firing immediately
This commit is contained in:
Chris Bianca 2018-04-30 10:20:58 +01:00 committed by GitHub
commit 19266d4bae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -657,7 +657,21 @@ public class RNFirebaseNotificationManager {
String notificationId = notification.getString("notificationId");
Bundle schedule = notification.getBundle("schedule");
Double fireDate = schedule.getDouble("fireDate");
// 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) {
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;
}
}
// Scheduled alarms are cleared on restart
// We store them so that they can be re-scheduled when the phone restarts in RNFirebaseNotificationsRebootReceiver