Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_local_notifications] Allow specifying start time of periodic notifications. #2503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ class FlutterLocalNotificationsPlugin {
NotificationDetails notificationDetails, {
required AndroidScheduleMode androidScheduleMode,
String? payload,
int? repeatStartTime,
}) async {
if (kIsWeb) {
return;
Expand All @@ -409,17 +410,22 @@ class FlutterLocalNotificationsPlugin {
?.periodicallyShow(id, title, body, repeatInterval,
notificationDetails: notificationDetails.android,
payload: payload,
scheduleMode: androidScheduleMode);
scheduleMode: androidScheduleMode,
repeatStartTime: repeatStartTime);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
await resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.periodicallyShow(id, title, body, repeatInterval,
notificationDetails: notificationDetails.iOS, payload: payload);
notificationDetails: notificationDetails.iOS,
payload: payload,
repeatStartTime: repeatStartTime);
} else if (defaultTargetPlatform == TargetPlatform.macOS) {
await resolvePlatformSpecificImplementation<
MacOSFlutterLocalNotificationsPlugin>()
?.periodicallyShow(id, title, body, repeatInterval,
notificationDetails: notificationDetails.macOS, payload: payload);
notificationDetails: notificationDetails.macOS,
payload: payload,
repeatStartTime: repeatStartTime);
} else if (defaultTargetPlatform == TargetPlatform.windows) {
throw UnsupportedError('Notifications do not repeat on Windows');
} else {
Expand All @@ -446,6 +452,7 @@ class FlutterLocalNotificationsPlugin {
NotificationDetails notificationDetails, {
AndroidScheduleMode androidScheduleMode = AndroidScheduleMode.exact,
String? payload,
int? repeatStartTime,
}) async {
if (kIsWeb) {
return;
Expand All @@ -457,19 +464,24 @@ class FlutterLocalNotificationsPlugin {
id, title, body, repeatDurationInterval,
notificationDetails: notificationDetails.android,
payload: payload,
scheduleMode: androidScheduleMode);
scheduleMode: androidScheduleMode,
repeatStartTime: repeatStartTime);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
await resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.periodicallyShowWithDuration(
id, title, body, repeatDurationInterval,
notificationDetails: notificationDetails.iOS, payload: payload);
notificationDetails: notificationDetails.iOS,
payload: payload,
repeatStartTime: repeatStartTime);
} else if (defaultTargetPlatform == TargetPlatform.macOS) {
await resolvePlatformSpecificImplementation<
MacOSFlutterLocalNotificationsPlugin>()
?.periodicallyShowWithDuration(
id, title, body, repeatDurationInterval,
notificationDetails: notificationDetails.macOS, payload: payload);
notificationDetails: notificationDetails.macOS,
payload: payload,
repeatStartTime: repeatStartTime);
} else {
await FlutterLocalNotificationsPlatform.instance
.periodicallyShowWithDuration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,14 @@ class AndroidFlutterLocalNotificationsPlugin
AndroidNotificationDetails? notificationDetails,
String? payload,
AndroidScheduleMode scheduleMode = AndroidScheduleMode.exact,
int? repeatStartTime,
}) async {
validateId(id);
await _channel.invokeMethod('periodicallyShow', <String, Object?>{
'id': id,
'title': title,
'body': body,
'calledAt': clock.now().millisecondsSinceEpoch,
'calledAt': repeatStartTime ?? clock.now().millisecondsSinceEpoch,
'repeatInterval': repeatInterval.index,
'platformSpecifics':
_buildPlatformSpecifics(notificationDetails, scheduleMode),
Expand All @@ -377,6 +378,7 @@ class AndroidFlutterLocalNotificationsPlugin
AndroidNotificationDetails? notificationDetails,
String? payload,
AndroidScheduleMode scheduleMode = AndroidScheduleMode.exact,
int? repeatStartTime,
}) async {
validateId(id);
validateRepeatDurationInterval(repeatDurationInterval);
Expand All @@ -385,7 +387,7 @@ class AndroidFlutterLocalNotificationsPlugin
'id': id,
'title': title,
'body': body,
'calledAt': clock.now().millisecondsSinceEpoch,
'calledAt': repeatStartTime ?? clock.now().millisecondsSinceEpoch,
'repeatIntervalMilliseconds': repeatDurationInterval.inMilliseconds,
'platformSpecifics':
_buildPlatformSpecifics(notificationDetails, scheduleMode),
Expand Down Expand Up @@ -754,13 +756,14 @@ class IOSFlutterLocalNotificationsPlugin
RepeatInterval repeatInterval, {
DarwinNotificationDetails? notificationDetails,
String? payload,
int? repeatStartTime,
}) async {
validateId(id);
await _channel.invokeMethod('periodicallyShow', <String, Object?>{
'id': id,
'title': title,
'body': body,
'calledAt': clock.now().millisecondsSinceEpoch,
'calledAt': repeatStartTime ?? clock.now().millisecondsSinceEpoch,
'repeatInterval': repeatInterval.index,
'platformSpecifics': notificationDetails?.toMap(),
'payload': payload ?? ''
Expand All @@ -775,6 +778,7 @@ class IOSFlutterLocalNotificationsPlugin
Duration repeatDurationInterval, {
DarwinNotificationDetails? notificationDetails,
String? payload,
int? repeatStartTime,
}) async {
validateId(id);
validateRepeatDurationInterval(repeatDurationInterval);
Expand All @@ -783,7 +787,7 @@ class IOSFlutterLocalNotificationsPlugin
'id': id,
'title': title,
'body': body,
'calledAt': clock.now().millisecondsSinceEpoch,
'calledAt': repeatStartTime ?? clock.now().millisecondsSinceEpoch,
'repeatIntervalMilliseconds': repeatDurationInterval.inMilliseconds,
'platformSpecifics': notificationDetails?.toMap(),
'payload': payload ?? ''
Expand Down Expand Up @@ -948,13 +952,14 @@ class MacOSFlutterLocalNotificationsPlugin
RepeatInterval repeatInterval, {
DarwinNotificationDetails? notificationDetails,
String? payload,
int? repeatStartTime,
}) async {
validateId(id);
await _channel.invokeMethod('periodicallyShow', <String, Object?>{
'id': id,
'title': title,
'body': body,
'calledAt': clock.now().millisecondsSinceEpoch,
'calledAt': repeatStartTime ?? clock.now().millisecondsSinceEpoch,
'repeatInterval': repeatInterval.index,
'platformSpecifics': notificationDetails?.toMap(),
'payload': payload ?? ''
Expand All @@ -969,6 +974,7 @@ class MacOSFlutterLocalNotificationsPlugin
Duration repeatDurationInterval, {
DarwinNotificationDetails? notificationDetails,
String? payload,
int? repeatStartTime,
}) async {
validateId(id);
validateRepeatDurationInterval(repeatDurationInterval);
Expand All @@ -977,7 +983,7 @@ class MacOSFlutterLocalNotificationsPlugin
'id': id,
'title': title,
'body': body,
'calledAt': clock.now().millisecondsSinceEpoch,
'calledAt': repeatStartTime ?? clock.now().millisecondsSinceEpoch,
'repeatIntervalMilliseconds': repeatDurationInterval.inMilliseconds,
'platformSpecifics': notificationDetails?.toMap(),
'payload': payload ?? ''
Expand Down