I'm trying to play my own custom sound for my notifications. But on my android emulator, it just plays the default sound and on my own device, it doesn't even make a sound. I tried this but it didn't help me.
FlutterLocalNotificationsPlugin _notifications = FlutterLocalNotificationsPlugin();
var initializationSettingsAndroid = AndroidInitializationSettings('app_icon');
var initializationSettingsIOS = IOSInitializationSettings();
var initializationSettings = InitializationSettings(initializationSettingsAndroid, initializationSettingsIOS);
await _notifications.initialize(initializationSettings);
var androidPlatformChannelSpecifics = AndroidNotificationDetails('test_channel', 'test', '', playSound: true, sound: RawResourceAndroidNotificationSound('my_sound'));
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await _notifications.show(0, 'test', 'this is a test', platformChannelSpecifics);
I don't get any errors. My file is in android/app/src/main/res/raw/my_sound.mp3
Simple fix! You have to uninstall and reinstall the app completely instead of just updating it. The notification settings from your first install will persist, so if it was once set to default sound, that will persist if you don't change the channel id. More info here
According to the doc: "For Android 8.0 or newer, this (sound) is tied to the specified channel and cannot be changed after the channel has been created for the first time."
So, either create a separate channel or just uninstall the application to delete the notification channel and reinstall it.
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