如何解决通知声音在颤振中不起作用 flutter_local_notifications
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 举报,一经查实,本站将立刻删除。