简体   繁体   中英

Custom notification sound is not working on flutter

I had implemented notification with Firebase, and the notification is working properly. But I need to play a custom sound for notification. I had implemented

playSound: true, sound: const RawResourceAndroidNotificationSound('notification'),

and added sound in android\app\src\main\res\raw folder which is named 'notification.mp3'. But no sound is playing on notification works.

Also implemented code in the payload.

Code from main function flutter:

来自主函数的代码颤动。

Code from Payload or server:

来自负载或服务器的代码。

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..

"sound": "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. Anyway .mp3 is not a valid APN notification file format, and you need to specify also the file extention.

"sound": "filename.caf"

Follow Apple documentation in order to forge your custom sound file for your app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM