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
How to Delete an Image from Photolibrary After I Pick It Up Using Uiimagepickercontroller
Uitextfield Doesn't End Editing When Button Clicked( Delegate Textfielddidendediting )
How to Run a Task in Swift on a Particular Date-Time in Background Either Application Is on or Off
How Do View Types Like Text or Image Conform to the View Protocol in Swiftui
Wake Up Application in Background Using Audiosession Like Alarmy iOS App
Ios10, Swift 3, and Fcm Delegate Error
Core Data Entity Unique Constraint Does Not Work
Avmutablecomposition Resizing Issue
Pass Data from View Controller to Child Controller in Swift
How to Trigger an API Call Before Displaying Local Notifications
Swift Scenekit - Centering Scntext - the Getboundingboxmin:Max Issue
How to Use a Generic Class Without the Type Argument in Swift
How to Use a Custom Initializer on a Uitableviewcell
How to Manage and Free Memory Through Viewcontrollers
Self.Type Cannot Be Directly Converted to Anyclass in Extension to Objective-C Class in Swift