Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Local Notification Sound not working

The notification sound using Flutter Local Notification for Android not working at all here is the code

const NotificationDetails(
          android: AndroidNotificationDetails(
            'daily notification channel id',
            'daily notification channel name',
            'daily notification description',
            playSound: true,
            sound: RawResourceAndroidNotificationSound('pop'),
            importance: Importance.max,
            priority: Priority.high,
          ),
        ),

And I have pop.mp3 in this path: \android\app\src\main\res\raw\pop.mp3

How can I play the sound?

like image 225
Ammar Mohamed Avatar asked Mar 09 '26 10:03

Ammar Mohamed


2 Answers

For Android 8.0+, sounds and vibrations are associated with notification channels and can only be configured when they are first created. Showing/scheduling a notification will create a channel with the specified id if it doesn't exist already. If another notification specifies the same channel id but tries to specify another sound or vibration pattern then nothing occurs.

Solution => Please change Channel id, name, description, it will be fine.

like image 140
Hawar Hekmat Avatar answered Mar 12 '26 01:03

Hawar Hekmat


My problem was that I was testing the app on Xiaomi and I realized that Xiaomi has some problems and it by default doesn't allow notification sound. Somehow it didn't work on the emulator too, but by testing it on other physical devices it worked.

like image 39
Ammar Mohamed Avatar answered Mar 11 '26 23:03

Ammar Mohamed