如何在 Awesome notification 中自定义通知声音

问题描述 投票:0回答:1

我正在尝试用我的

alarm.wav
声音创建一个警报通知。我听了一些教程,发现我需要将我的声音放在
android/app/src/main/res/raw
中。当尝试使用
awesome_notifications
包推送通知时,它只播放默认的设备通知声音。有人可以看看我是否做错了什么,因为没有弹出错误。

AwesomeNotifications().createNotification(
        content: NotificationContent(
            id: id,
            actionType: actionType,
            title: title,
            category: NotificationCategory.Alarm,
            criticalAlert: true,
            wakeUpScreen: true,
            channelKey: 'high_importance_channel',
            body: body,
            customSound: "resource://raw/alarm",
            // payload: json.decode(payLoad),
            ),
     );

编辑

我还尝试将路径作为我的 soundSource 参数传递,但给了我这个错误:

[Awesome Notifications](12613): Audio media is not valid (NotificationChannelModel:58)

代码:

await AwesomeNotifications().initialize(null, [
      NotificationChannel(
        channelKey: 'high_importance_channel',
        channelName: 'alert_channel',
        channelDescription: 'Alert user from certain health issues',
        playSound: true,
        soundSource: "resource://raw/alarm",
      )
    ]);
flutter push-notification awesome-notifications
1个回答
0
投票

如果您解决了这个问题请告诉我!

© www.soinside.com 2019 - 2024. All rights reserved.