periodicallyShow method
Future<void>
periodicallyShow(
- int id,
- String? title,
- String? body,
- RepeatInterval repeatInterval,
- NotificationDetails notificationDetails, {
- required AndroidScheduleMode androidScheduleMode,
- String? payload,
Periodically show a notification using the specified interval.
For example, specifying a hourly interval means the first time the notification will be an hour after the method has been called and then every hour after that.
On Android, this will also require additional setup for the app,
especially in the app's AndroidManifest.xml
file. Please see check the
readme for further details.
Implementation
Future<void> periodicallyShow(
int id,
String? title,
String? body,
RepeatInterval repeatInterval,
NotificationDetails notificationDetails, {
required AndroidScheduleMode androidScheduleMode,
String? payload,
}) async {
if (kIsWeb) {
return;
}
if (defaultTargetPlatform == TargetPlatform.android) {
await resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.periodicallyShow(id, title, body, repeatInterval,
notificationDetails: notificationDetails.android,
payload: payload,
scheduleMode: androidScheduleMode);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
await resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.periodicallyShow(id, title, body, repeatInterval,
notificationDetails: notificationDetails.iOS, payload: payload);
} else if (defaultTargetPlatform == TargetPlatform.macOS) {
await resolvePlatformSpecificImplementation<
MacOSFlutterLocalNotificationsPlugin>()
?.periodicallyShow(id, title, body, repeatInterval,
notificationDetails: notificationDetails.macOS, payload: payload);
} else {
await FlutterLocalNotificationsPlatform.instance
.periodicallyShow(id, title, body, repeatInterval);
}
}