简体   繁体   English

自定义通知声音不适用于 flutter

[英]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.

相关问题 如何为 firebase 推送通知添加自定义通知声音 - Flutter - How to add custom notification sound for firebase push notification - Flutter Android 推送通知的自定义声音不起作用 (FCM) - Custom sound for Android Push Notification not working (FCM) 如何使用 firebase 通知为 flutter 应用程序启用通知声音? - How to enable notification sound for flutter app using firebase notification? flutter 中 FCM 的自定义通知通道 - Custom notification channel for FCM in flutter flutter中的FCM自定义通知图标 - FCM Custom Notification Icon in flutter Firebase 通知消息 Android 11 上没有自定义声音(旧版) - Firebase notification message no custom sound on Android 11 (legacy) react-native-firebase 在收到通知时播放自定义声音 - react-native-firebase play custom sound on notification arrived firebase 推送通知声音在 android 工作室中的 android 应用程序上不起作用 - firebase push notification sound not working on android app in android studio 自定义 iOS 通知声音 本地通知 package Flutter - Custom iOS notifications sound local notifications package Flutter Flutter Firebase 前台推送通知未显示,但后台正在工作 - Flutter Firebase foreground push notification not showing but background is working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM