我正在构建一个带有 firebase 通知的 flutter 应用程序。但是,我需要自定义声音来进行通知。我已经在 AndroidNotificationDetails 下实现了 playSound: true, sound: RawResourceAndroidNotificationSound('notification'),
并将 mp3 文件复制到正确位置的 raw 文件夹中,但没有用。有人能解决这个问题吗?
最佳答案
将此声音键添加到您的通知负载中
{
"to" : "AsS23rH5543:CI2k_AsS23rH5543CIZvvDMAsS23rH5543P1...",
"notification" : {
"body" : "your body",
"title" : "Your Title",
"icon" : "your icon",
"sound" : "default"
}
}
如果您需要更多帮助,请参阅此 link
关于android - 如何使用 firebase 通知为 flutter 应用程序启用通知声音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71761147/