MaikuB / flutter_local_notifications

A Flutter plugin for displaying local notifications on Android, iOS, macOS and Linux
2.47k stars 1.4k forks source link

Notification sound not playing on Android #1327

Closed LaxmikanthMadhyastha closed 3 years ago

LaxmikanthMadhyastha commented 3 years ago

Describe the bug Notification sound not coming in the example app I downloaded the example project and ran it on my OnePlus 7 Pro directly without modifying any code using the flutter run --release, when I click on any of the options on the main page, the notification appears on the notification panel, but there is no default sound being played or the custom sound being played upon clicking the button

PS: I have disabled the battery optimization option as well

One thing I observed is that when the notification appears on the notification panel and upon long-pressing the notification, it shows the importance of that notification as Others though in the example project priority is set to high and importance is set to max (Image 1).

1

If I got to app settings and view the settings for that notification channel it still says Important

2

However, if I click on Others and then click on Important again in the above picture then the notification sound plays

I have attached a screen recording for better understanding.

https://user-images.githubusercontent.com/35574146/136550867-f8eb43c1-e762-4fea-ac9a-5e0456198166.mp4

To Reproduce

  1. Clone the example repo
  2. Click on "Show notification with custom sound "
  3. Notification will come but without any sound

Expected behavior Notification should come with custom sound

PS: Even other notifications also appearing without the default notification sound


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-x64, locale en-IN) • Flutter version 2.5.2 at /Users/laxmikant/Desktop/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 3595343e20 (8 days ago), 2021-09-30 12:58:18 -0700 • Engine revision 6ac856380f • Dart version 2.14.3 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/laxmikant/Library/Android/sdk • Platform android-30, build-tools 30.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.4, Build version 12D4e • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) [✓] VS Code (version 1.60.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.27.0 [✓] Connected device (2 available) • GM1911 (mobile) • 02a43144 • android-arm64 • Android 11 (API 30) • Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.71 ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 2.14.3 Flutter SDK 2.5.2 flutter_local_notifications_example 0.0.0 dependencies: - cupertino_icons 1.0.3 - device_info 2.0.2 [flutter device_info_platform_interface] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_local_notifications 9.0.0 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_native_timezone 1.1.0 [flutter_web_plugins flutter js] - http 0.13.4 [async http_parser meta path] - image 3.0.8 [archive meta xml] - path_provider 2.0.5 [flutter path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - rxdart 0.26.0 - shared_preferences 2.0.8 [flutter meta shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] dev dependencies: - flutter_driver 0.0.0 [file flutter flutter_test fuchsia_remote_debug_protocol path meta vm_service webdriver archive async boolean_selector characters charcode clock collection crypto matcher platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] - integration_test 0.0.0 [flutter flutter_driver flutter_test path vm_service archive async boolean_selector characters charcode clock collection crypto fake_async file matcher meta source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math webdriver] transitive dependencies: - archive 3.1.2 [crypto path] - args 2.3.0 - async 2.8.1 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - characters 1.1.0 - charcode 1.3.1 - clock 1.1.0 - collection 1.15.0 - crypto 3.0.1 [collection typed_data] - dbus 0.5.6 [args ffi meta pedantic xml] - device_info_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - fake_async 1.2.0 [clock collection] - ffi 1.1.2 - file 6.1.2 [meta path] - flutter_local_notifications_linux 0.3.0 [flutter flutter_local_notifications_platform_interface dbus path xdg_directories] - flutter_local_notifications_platform_interface 5.0.0 [flutter plugin_platform_interface] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - js 0.6.3 - matcher 0.12.10 [stack_trace] - meta 1.7.0 - path 1.8.0 - path_provider_linux 2.1.0 [flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.2 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.3 [ffi flutter meta path path_provider_platform_interface win32] - pedantic 1.11.1 - petitparser 4.3.0 [meta] - platform 3.0.0 - plugin_platform_interface 2.0.2 [meta] - process 4.2.3 [file path platform] - shared_preferences_linux 2.0.2 [file meta flutter path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 2.0.2 [flutter shared_preferences_platform_interface] - shared_preferences_platform_interface 2.0.0 [flutter] - shared_preferences_web 2.0.2 [flutter flutter_web_plugins meta shared_preferences_platform_interface] - shared_preferences_windows 2.0.2 [flutter file meta path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - sky_engine 0.0.99 - source_span 1.8.1 [collection path term_glyph] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.0 [charcode source_span] - sync_http 0.3.0 - term_glyph 1.2.0 - test_api 0.4.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.8.0 [path] - typed_data 1.3.0 [collection] - vector_math 2.1.0 - vm_service 7.1.1 - webdriver 3.0.0 [archive matcher path stack_trace sync_http] - win32 2.2.9 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.3.0 [collection meta petitparser]```

dhruv048 commented 3 years ago

Facing same issue Works fine for samsung devices but not for OnePlus :(

MaikuB commented 3 years ago

This is something you would need to research on when it comes to Android OEMs doing their own custom implementation of Android as these issues are outside the control of this plugin. It might be they require other settings to be changed but because other OEMs are applying customisations, it's not part of the standard Android OS that there'd be APIs for it. If you run this on stock Android devices e.g. emulator, Pixel phones it works fine. So to summarise, there's nothing that can be done on the plugin side.

ParhaMDeF commented 1 year ago

have same issue with android 9