Custom notification sound is not working on flutter

4.8k Views Asked by At

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 main function flutter.

Code from Payload or server:

Code from payload or server.

1

There are 1 best solutions below

0
hari patel On

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.