diff --git a/local-notifications/README.md b/local-notifications/README.md
index c88bde1a3..8d732af65 100644
--- a/local-notifications/README.md
+++ b/local-notifications/README.md
@@ -495,7 +495,7 @@ Use either `at`, `on`, or `every` to schedule notifications.
| **`at`** | Date | Schedule a notification at a specific date and time. | 1.0.0 |
| **`repeats`** | boolean | Repeat delivery of this notification at the date and time specified by `at`. Only available for iOS and Android. | 1.0.0 |
| **`allowWhileIdle`** | boolean | Allow this notification to fire while in [Doze](https://developer.android.com/training/monitoring-device-state/doze-standby) Note that these notifications can only fire [once per 9 minutes, per app](https://developer.android.com/training/monitoring-device-state/doze-standby#assessing_your_app). | 1.0.0 |
-| **`on`** | ScheduleOn | Schedule a notification on particular interval(s). This is similar to scheduling [cron](https://en.wikipedia.org/wiki/Cron) jobs. Only available for iOS and Android. | 1.0.0 |
+| **`on`** | ScheduleOn | Schedule a notification on particular interval(s). This is similar to scheduling [cron](https://en.wikipedia.org/wiki/Cron) jobs. Only available for iOS and Android. When the `at` property is defined additionally, then the first notification is postponed to that specific date and time (Android only). | 1.0.0 |
| **`every`** | ScheduleEvery | Schedule a notification on a particular interval. | 1.0.0 |
| **`count`** | number | Limit the number times a notification is delivered by the interval specified by `every`. | 1.0.0 |
diff --git a/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java b/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java
index 0b826a546..02599ae01 100644
--- a/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java
+++ b/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java
@@ -332,6 +332,21 @@ private void triggerScheduledNotification(Notification notification, LocalNotifi
}
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, request.getId(), notificationIntent, flags);
+ // Cron like scheduler
+ DateMatch on = schedule.getOn();
+ if (on != null) {
+ Date startDate = schedule.getAt() == null
+ ? new Date()
+ : schedule.getAt();
+ long trigger = on.nextTrigger(startDate);
+ notificationIntent.putExtra(TimedNotificationPublisher.CRON_KEY, on.toMatchString());
+ pendingIntent = PendingIntent.getBroadcast(context, request.getId(), notificationIntent, flags);
+ setExactIfPossible(alarmManager, schedule, trigger, pendingIntent);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+ Logger.debug(Logger.tags("LN"), "notification " + request.getId() + " will next fire at " + sdf.format(new Date(trigger)));
+ return;
+ }
+
// Schedule at specific time (with repeating support)
Date at = schedule.getAt();
if (at != null) {
@@ -356,18 +371,6 @@ private void triggerScheduledNotification(Notification notification, LocalNotifi
long startTime = new Date().getTime() + everyInterval;
alarmManager.setRepeating(AlarmManager.RTC, startTime, everyInterval, pendingIntent);
}
- return;
- }
-
- // Cron like scheduler
- DateMatch on = schedule.getOn();
- if (on != null) {
- long trigger = on.nextTrigger(new Date());
- notificationIntent.putExtra(TimedNotificationPublisher.CRON_KEY, on.toMatchString());
- pendingIntent = PendingIntent.getBroadcast(context, request.getId(), notificationIntent, flags);
- setExactIfPossible(alarmManager, schedule, trigger, pendingIntent);
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- Logger.debug(Logger.tags("LN"), "notification " + request.getId() + " will next fire at " + sdf.format(new Date(trigger)));
}
}