firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.73k stars 3.98k forks source link

🐛 [firebase_messaging] Android authorization status not reflecting system settings #4492

Closed philiplindberg closed 3 years ago

philiplindberg commented 3 years ago

Bug report

Getting the authorizationStatus from _messaging.getNotificationSettings() on Android always returns AuthorizationStatus.authorized, even if push notifications are disabled for the app in system settings.

Steps to reproduce

Steps to reproduce the behavior:

  1. On Android, call (await _messaging.getNotificationSettings()).authorizationStatus and confirm that AuthorizationStatus.authorized is returned.
  2. In Android system settings, go to Apps & notifications, find the app in question, tap on Notifications on the App info screen, and toggle the "All notifications" switch to off.
  3. Back in our app, call (await _messaging.getNotificationSettings()).authorizationStatus again. Even though notifications have been disabled in system settings, this method still returns AuthorizationStatus.authorized.

Expected behavior

If notifications have been disabled in system settings, calling (await _messaging.getNotificationSettings()).authorizationStatus should return AuthorizationStatus.denied. This is currently happening on iOS, but not on Android.

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [✓] Flutter (Channel stable, 1.22.4, on macOS 11.1 20C69 darwin-x64, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 12.3) [✓] Android Studio (version 4.0) [✓] VS Code (version 1.52.1) [✓] Connected device (2 available) • No issues found! ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.10.4 Flutter SDK 1.22.4 mobile 1.9.1+1901 dependencies: - assets_audio_player 2.0.10 [flutter rxdart uuid http path_provider assets_audio_player_web] - cached_network_image 2.3.3 [flutter flutter_cache_manager octo_image] - camera 0.5.8+9 [flutter] - device_info 0.4.2+9 [flutter device_info_platform_interface] - dio 3.0.10 [http_parser path] - dio_cookie_manager 1.0.0 [cookie_jar dio] - dotted_border 1.0.6 [flutter path_drawing] - equatable 1.2.5 [collection meta] - exif 1.0.3 [args collection convert sprintf] - firebase_analytics 6.2.0 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface] - firebase_core 0.5.2 [firebase_core_platform_interface flutter quiver meta firebase_core_web] - firebase_dynamic_links 0.6.0+2 [flutter firebase_core] - firebase_messaging 8.0.0-dev.8 [meta flutter firebase_core firebase_core_platform_interface firebase_messaging_platform_interface] - firebase_ml_vision 0.9.9 [flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_dotenv 2.1.0 [flutter meta] - flutter_local_notifications 2.0.1+1 [flutter platform flutter_local_notifications_platform_interface timezone] - flutter_markdown 0.5.1 [flutter markdown meta path] - flutter_pdfview 1.0.0+10 [flutter] - flutter_svg 0.19.0 [path_drawing xml vector_math meta flutter] - flutter_swiper 1.1.6 [flutter transformer_page_view flutter_page_indicator] - image_cropper 1.3.1 [flutter] - image_picker 0.6.7+12 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - intl 0.16.1 [path] - local_auth 0.6.3+3 [flutter meta intl platform flutter_plugin_android_lifecycle] - location 3.0.2 [flutter meta location_platform_interface location_web] - logging 0.11.4 - map_launcher 0.12.2 [flutter flutter_svg] - mapbox_gl 0.9.0 [flutter mapbox_gl_platform_interface mapbox_gl_web] - package_info 0.4.3 [flutter] - path_provider 1.6.21 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - permission_handler 5.0.1+1 [flutter meta permission_handler_platform_interface] - provider 4.3.2+2 [flutter nested collection] - qr_flutter 3.2.0 [flutter qr] - share 0.6.5+4 [meta mime flutter] - shared_preferences 0.5.12+2 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows] - simple_gesture_detector 0.1.4 [flutter] - stripe_payment 1.0.8 [flutter] - twilio_programmable_video 0.6.3+1 [flutter permission_handler enum_to_string twilio_programmable_video_platform_interface] - url_launcher 5.7.5 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows] - uuid 2.2.2 [crypto convert] - vibration 1.7.1 [flutter vibration_web] - video_player 1.0.1 [meta video_player_platform_interface video_player_web flutter] - wakelock 0.2.0+1 [flutter meta wakelock_platform_interface wakelock_web] - webview_flutter 1.0.3 [flutter] - xml 4.5.1 [collection convert meta petitparser] dev dependencies: - flutter_launcher_icons 0.8.1 [image args yaml path] - 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] transitive dependencies: - archive 2.0.13 [crypto args path] - args 1.6.0 - assets_audio_player_web 2.0.9+2 [flutter flutter_web_plugins] - async 2.5.0-nullsafety.1 [collection] - boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner] - characters 1.1.0-nullsafety.3 - charcode 1.2.0-nullsafety.1 - clock 1.1.0-nullsafety.1 - collection 1.15.0-nullsafety.3 - convert 2.1.1 [charcode typed_data] - cookie_jar 1.0.1 - crypto 2.1.5 [collection convert typed_data] - csslib 0.16.2 [source_span] - device_info_platform_interface 1.0.1 [flutter meta plugin_platform_interface] - enum_to_string 1.0.13 - fake_async 1.2.0-nullsafety.1 [clock collection] - ffi 0.1.3 - file 5.2.1 [intl meta path] - firebase 7.3.2 [http http_parser js] - firebase_analytics_platform_interface 1.0.3 [flutter meta] - firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta] - firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver] - firebase_core_web 0.2.1 [firebase_core_platform_interface flutter flutter_web_plugins meta js] - firebase_messaging_platform_interface 1.0.0-dev.5 [flutter meta firebase_core plugin_platform_interface] - flutter_blurhash 0.5.0 [flutter meta] - flutter_cache_manager 2.0.0 [flutter path_provider uuid http path sqflite pedantic clock file rxdart] - flutter_local_notifications_platform_interface 2.0.0 [flutter plugin_platform_interface] - flutter_page_indicator 0.0.3 [flutter] - flutter_plugin_android_lifecycle 1.0.11 [flutter] - flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math] - html 0.14.0+4 [csslib source_span] - http 0.12.2 [http_parser path pedantic] - http_parser 3.1.4 [charcode collection source_span string_scanner typed_data] - image 2.1.18 [archive xml meta] - image_picker_platform_interface 1.1.1 [flutter meta http plugin_platform_interface] - import_js_library 1.0.1 [flutter html flutter_web_plugins js] - js 0.6.2 - location_platform_interface 1.0.0 [flutter meta plugin_platform_interface] - location_web 1.0.0 [flutter flutter_web_plugins location_platform_interface http_parser meta js] - mapbox_gl_dart 0.1.5 [js meta] - mapbox_gl_platform_interface 0.9.0 [flutter meta] - mapbox_gl_web 0.9.0 [flutter flutter_web_plugins meta mapbox_gl_platform_interface mapbox_gl_dart image] - markdown 3.0.0 [args charcode meta] - matcher 0.12.10-nullsafety.1 [stack_trace] - meta 1.3.0-nullsafety.3 - mime 0.9.7 - nested 0.0.4 [flutter] - octo_image 0.3.0 [flutter flutter_blurhash] - path 1.8.0-nullsafety.1 - path_drawing 0.4.1+1 [vector_math meta path_parsing flutter] - path_parsing 0.1.4 [vector_math meta] - path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 0.0.4+4 [flutter] - path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface] - path_provider_windows 0.0.4+1 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.9.2 [meta] - permission_handler_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - petitparser 3.1.0 [meta] - platform 2.2.1 - plugin_platform_interface 1.0.3 [meta] - process 3.0.13 [file intl meta path platform] - qr 1.3.0 [meta] - quiver 2.1.3 [matcher meta] - rxdart 0.24.1 - shared_preferences_linux 0.0.2+2 [file flutter meta path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 0.0.1+10 [shared_preferences_platform_interface flutter] - shared_preferences_platform_interface 1.0.4 [meta flutter] - shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta] - shared_preferences_windows 0.0.1+1 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows] - sky_engine 0.0.99 - source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph] - sprintf 4.1.0 - sqflite 1.3.1+1 [flutter sqflite_common path] - sqflite_common 1.0.2+1 [synchronized path meta] - stack_trace 1.10.0-nullsafety.1 [path] - stream_channel 2.1.0-nullsafety.1 [async] - string_scanner 1.1.0-nullsafety.1 [charcode source_span] - synchronized 2.2.0+2 - term_glyph 1.2.0-nullsafety.1 - test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.5.7 [path] - transformer_page_view 0.1.6 [flutter] - twilio_programmable_video_platform_interface 0.2.3 [flutter meta enum_to_string plugin_platform_interface collection equatable] - typed_data 1.3.0-nullsafety.3 [collection] - url_launcher_linux 0.0.1+1 [flutter] - url_launcher_macos 0.0.1+8 [flutter] - url_launcher_platform_interface 1.0.8 [flutter meta plugin_platform_interface] - url_launcher_web 0.1.4+1 [url_launcher_platform_interface flutter flutter_web_plugins meta] - url_launcher_windows 0.0.1+1 [flutter] - vector_math 2.1.0-nullsafety.3 - vibration_web 1.6.2 [flutter flutter_web_plugins] - video_player_platform_interface 2.2.0 [flutter meta] - video_player_web 0.1.4 [flutter flutter_web_plugins meta video_player_platform_interface] - wakelock_platform_interface 0.1.0 [flutter meta] - wakelock_web 0.1.0+2 [flutter flutter_web_plugins import_js_library js wakelock_platform_interface] - win32 1.7.3 [ffi] - xdg_directories 0.1.2 [meta path process] - yaml 2.2.1 [charcode collection string_scanner source_span] ```

ksadeaf commented 3 years ago

Yes

markusaksli-nc commented 3 years ago

This is reproducible on the latest master 1.26.0-2.0.pre.137 with the official example on firebase_messaging: ^8.0.0-dev.11.

flutter doctor -v ``` [√] Flutter (Channel master, 1.26.0-2.0.pre.137, on Microsoft Windows [Version 10.0.19041.685], locale et-EE) • Flutter version 1.26.0-2.0.pre.137 at C:\Development\flutter_master • Framework revision 8f5d0371af (2 days ago), 2020-12-26 11:07:36 +0330 • Engine revision f5364860ab • Dart version 2.12.0 (build 2.12.0-179.0.dev) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at C:\Users\marku\AppData\Local\Android\sdk • Platform android-30, build-tools 30.0.2 • Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6953283\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.7.30621.155 • Windows 10 SDK version 10.0.18362.0 [√] Android Studio (version 4.1.0) • Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6953283 • 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-b01) [√] IntelliJ IDEA Ultimate Edition (version 2020.3) • IntelliJ at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\203.5981.155 • 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 [√] Connected device (4 available) • SM G950F (mobile) • ce12171c51cc001c03 • android-arm64 • Android 9 (API 28) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19041.685] • Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.88 • Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.66 • No issues found!
JTPenn-EG commented 3 years ago

Is there any plans to support AuthorizationStatus on Android ?

shaiwals commented 3 years ago

Im facing the same issue. My app depends on being able to get valid notification permission status to warn the user that they may be missing important notifications. I am unable to display this warning on Android because of this issue. It impacts the apps ability to re-engage the user. Im using version 9.1.4

russellwheatley commented 3 years ago

Android devices by default do not require permission to receive notifications on a per app basis like Apple devices. Therefore, authorized will always be returned on android devices as documented here. If the user has a system wide notification block, you can implement libraries such as notification_permissions that check at the system level for such a thing, and will return denied if blocked. That library can also open settings to prompt the user to change permissions as referenced here.

shaiwals commented 3 years ago

@russellwheatley isn’t the whole point of flutter to minimize custom code per platform. It would be great if the plug-in team could fix it.