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.

Share:
2,007
Ammar Mohamed
Author by

Ammar Mohamed

Updated on December 01, 2022

Comments

  • Ammar Mohamed
    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
    Admin over 2 years
    Please add further details to expand on your answer, such as working code or documentation citations.
  • Chris
    Chris over 2 years
    I 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
    Chris about 2 years
    You 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 the Priority and Importance params.
  • Mostafa Alazhariy
    Mostafa Alazhariy about 2 years
    I 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.