问题描述
Future scheduleAlarmWithSound(Task task) async {
final exists = await _checkIfAlreadyScheduled(task.id);
if (exists) return;
var scheduleNotificationDateTime =
DateTime.fromMillisecondsSinceEpoch(task.endTime);
const AndroidNotificationDetails androidplatformChannelSpecifics =
AndroidNotificationDetails('v1','Todo','Reminder',icon: 'icon',importance: Importance.max,priority: Priority.high,largeIcon: DrawableResourceAndroidBitmap('icon'),sound: RawResourceAndroidNotificationSound('annoyingalarm'),playSound: true,showWhen: true);
const NotificationDetails platformChannelSpecifics =
NotificationDetails(android: androidplatformChannelSpecifics);
await FlutterlocalnotificationsPlugin.schedule(
task.id,task.task,'Time\'s up!\n Did you completed the task?\nIf not better luck next time.',scheduleNotificationDateTime,platformChannelSpecifics);
print("Alarm scheduled with sound");
}
Future scheduleAlarmWithoutSound(Task task) async {
final exists = await _checkIfAlreadyScheduled(task.id);
if (exists) return;
var scheduleNotificationDateTime =
DateTime.fromMillisecondsSinceEpoch(task.endTime);
const AndroidNotificationDetails androidplatformChannelSpecifics =
AndroidNotificationDetails('v1',playSound: false,'Time\'s up! Did you completed the task?',platformChannelSpecifics);
print("Alarm scheduled without sound");
}
首先,让我解释一下我的程序。这是一个提醒应用程序。如果我们单击提醒我按钮,则会设置带有警报声的通知,否则将设置没有警报声的通知。将来也可以选择更改此决定。问题是,当我设置带有闹钟声音通知的提醒时,没有播放声音。但是如果没有设置无声闹钟功能,则播放声音。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)