3

I am using the plugin flutter_local_notifications 6.0.0, where the user schedules a specific time to send the database.db file I was able to carry out the daily notification with the respective programming but I don't know where to call the function to execute it, even if the app is closed.

use the following code for local notification programming, but I need to call a function to send the .db file.

  Future<void> _scheduleDailyTenAMNotification(int hour, int minute) async {
await flutterLocalNotificationsPlugin.zonedSchedule(

    0,
    'Send Backup','',
    _nextInstanceOfTenAM(hour, minute),
    const NotificationDetails(
      android: AndroidNotificationDetails(
        'indeterminate progress channel',
        'indeterminate progress channel',
        'indeterminate progress channel description',
        channelShowBadge: false,
        importance: Importance.max,
        priority: Priority.high,
        onlyAlertOnce: true,
        showProgress: true,
        indeterminate: true)
    ),
    androidAllowWhileIdle: true,
    uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime,
    matchDateTimeComponents: DateTimeComponents.time);
}

 tz.TZDateTime _nextInstanceOfTenAM(int hour, int minute) {
  final tz.TZDateTime now = tz.TZDateTime.now(tz.local);
  tz.TZDateTime scheduledDate =
    tz.TZDateTime(tz.local, now.year, now.month, now.day, hour, minute);
  if (scheduledDate.isBefore(now)) {
    scheduledDate = scheduledDate.add(const Duration(days: 1));
  }
  return scheduledDate;
 }
Moisés Ochoa
  • 83
  • 2
  • 6

0 Answers0