Uilocalnotification: Playing a Custom Audio File Saved in Documents Directory

UILocalNotification: Playing a Custom Audio File saved in Documents Directory

The answer, unfortunately, is no and no.

You can only play sounds from the bundle in a local notification, and the bundle is read-only.

The only sounds you can play from a local notification must be shipped with your app. No other option.

Flutter local notification custom sound doesn't work (path issue)

thanks for sunnyque for giving awesome solution, but here's how i implemented it into my fcm,

first : you have to set "channel_id","playSound: true",
"sound: RawResourceAndroidNotificationSound('yourmp3files.mp3')"
:
adding specific channel on flutter_local_notification

Future displayNotification(Map<String, dynamic> message) async {
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'you_can_name_it_whatever',
'flutterfcm',
'flutterfcm',
playSound: true,
sound: RawResourceAndroidNotificationSound('yourmp3files.mp3'),
importance: Importance.max,
priority: Priority.high,
);

then, add mp3 file into res/raw/yourmp3files.mp3 adding mp3

after that you need to add keep.xml inside res/raw/keep.xml to include yourmp3files.mp3 into build keep.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@raw/yourmp3files"
/>

your done, now you can test the fcm custom sound in your app, do

uninstal last build

flutter clean

flutter pub get

flutter build apk

flutter run --release

tada , tell me if its work, hehe

i hope this help someone in the future /p>


Related Topics



Leave a reply



Submit