How to add custom mp3 sound in flutter_local_notification, there is a feature of adding custom ringtone but unfortunately no documentation or examples.
Add raw folder in android project : android>app>src>main>res> New Android Resource Directory > Select Raw > add your sound here
Result Folder :
- android
- app
- src
- main
- res
- raw
lawgo_sound_notification.mp3
image here : [1]: https://i.stack.imgur.com/EHquv.png
implement your local notification code:
var androidPlatformChannel = new AndroidNotificationDetails(
"your_channel_id", "name", "desc_channel",
sound: RawResourceAndroidNotificationSound('lawgo_sound_notification'),
playSound: true,
importance: Importance.Max,
priority: Priority.High);
add onResume, OnLaunch support, when apps run on background notification payload should be setup to this:
{ "notification" : {
"body" : "Body of Your Notification",
"title": "Title of Your Notification",
"android_channel_id": "your_channel_id"
},
"data" : {
"body" : "Body of Your Notification in Data",
"title": "Title of Your Notification in Title",
"click_action": "FLUTTER_NOTIFICATION_CLICK",
}
}
**important should add "android_channel_id": "default_notification_channel_id"**
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With