Flutter Local Notification Sound not working
2,007
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.
Author by
Ammar Mohamed
Updated on December 01, 2022Comments
-
Ammar Mohamed over 1 year
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?
-
Admin over 2 yearsPlease add further details to expand on your answer, such as working code or documentation citations.
-
Chris over 2 yearsI have been getting play store comments saying the notification sounds aren’t working on some devices, I’m thinking it could be the Xiaomi devices, did you find a fix?
-
Chris about 2 yearsYou could have just posted the
AndroidNotificationDetails
. However, they're only slightly different to the ones in the question and there's no explanation for not including thePriority
andImportance
params. -
Mostafa Alazhariy about 2 yearsI agree with you. I was facing the same problem on my Xiaomi phone and the notification sound was working fine in the emulator but not working on my phone, in the end, I discovered that my Xiaomi phone turned off the notification sound so I allowed it and it worked fine. You have to go to app settings then notification settings then allow notification sound and it will work fine.