[英]Custom notification sound is not working on flutter
I had implemented notification with Firebase, and the notification is working properly.我已经通过 Firebase 实施了通知,并且通知工作正常。 But I need to play a custom sound for notification.但我需要播放自定义声音以进行通知。 I had implemented我已经实施
playSound: true, sound: const RawResourceAndroidNotificationSound('notification'), playSound: true, 声音: const RawResourceAndroidNotificationSound('notification'),
and added sound in android\app\src\main\res\raw folder which is named 'notification.mp3'.并在名为“notification.mp3”的 android\app\src\main\res\raw 文件夹中添加了声音。 But no sound is playing on notification works.但是通知作品没有播放声音。
Also implemented code in the payload.还在有效负载中实现了代码。
Code from main function flutter:来自主 function flutter 的代码:
Code from Payload or server:来自 Payload 或服务器的代码:
Reading this it seems that it should be manage automatically (if you didn't use a notification builder ) on Android but you have to specify the.mp3 extension too and put it inside notification field and not data one..阅读这篇文章似乎它应该在 Android 上自动管理(如果你没有使用通知生成器),但你也必须指定 .mp3 扩展名并将其放在通知字段中而不是数据一..
"sound": "alarm.mp3" “声音”:“alarm.mp3”
iOS behaves very differently under the hood but you can use a custom sound by setting the sound: field in the notification payload too. iOS在后台的行为非常不同,但您也可以通过在通知有效负载中设置sound:字段来使用自定义声音。 Anyway .mp3 is not a valid APN notification file format, and you need to specify also the file extention.无论如何, .mp3不是有效的 APN 通知文件格式,您还需要指定文件扩展名。
"sound": "filename.caf" “声音”:“文件名.caf”
Follow Apple documentation in order to forge your custom sound file for your app.按照Apple 文档为您的应用程序伪造自定义声音文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.