0

我无法显示用户设置的不同时间间隔的通知,例如警报。我需要为不同的时间间隔设置提醒。我使用flutter_local_notifications来安排通知。还有另一种安排通知的方法吗?

帮助我找到解决方案。

这是我的代码

import 'package:timezone/data/latest.dart' as tz;
import 'package:timezone/timezone.dart' as tz;
import 'package:flutter_local_notifications/flutter_local_notifications.dart';




Future<void> scheduleNotification() async {
    var scheduleNotificationDateTime = reminderTime;
    var time = tz.TZDateTime.now(tz.local).add(Duration(
      seconds:20,
    ));


    var androidPlatformChannelSpecifics = AndroidNotificationDetails(
      'alarm_notif',
      'alarm_notif',
      'Channel for Alarm notification',
      importance: Importance.max,
      priority: Priority.high,
      icon: 'logo',
      sound: RawResourceAndroidNotificationSound(null),
      largeIcon: DrawableResourceAndroidBitmap('logo'),
    );
    var platformChannelSpecifics = NotificationDetails(
      android: androidPlatformChannelSpecifics,
    );
    await flutterLocalNotificationsPlugin.zonedSchedule(
      0,
      'Title',
      'Take your Medicine',
      time,
      platformChannelSpecifics,
      payload: 'task',
      androidAllowWhileIdle: true,
      uiLocalNotificationDateInterpretation:null,
    );
  }
4

0 回答 0