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.72k stars 3.97k forks source link

🐛 [firebase_messaging] Cannot register background handler #8059

Closed smsimone closed 2 years ago

smsimone commented 2 years ago

Bug report

When registering a background handler, I receive the error Null check operator used on a null value. Error thrown null. on line 180 of method_channel_messaging.dart, which is:

final CallbackHandle userHandle = PluginUtilities.getCallbackHandle(handler)!;

while on iOS it seems to never happen.


Additional context

On Crashlytics the stacktrace uploaded for this error is:

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Null check operator used on a null value. Error thrown null.
       at MethodChannelFirebaseMessaging.registerBackgroundMessageHandler(method_channel_messaging.dart:180)
       at FirebaseMessagingPlatform.onBackgroundMessage=(platform_interface_messaging.dart:102)
       at FirebaseMessaging.onBackgroundMessage(messaging.dart:73)
       at GmsMessaging.backgroundHandler=(gms_messaging.dart:22)
       at Messaging.init(messaging.dart:256)

Flutter doctor

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.10.0, on macOS 12.1 21C52 darwin-arm, locale it) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) [✓] Android Studio (version 2021.1) [✓] Android Studio (version 2020.3) [☠] IntelliJ IDEA Ultimate Edition (the doctor check crashed) ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues. ✗ FormatException: Unexpected extension byte (at offset 5) [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2) [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.1) [✓] VS Code (version 1.64.1) [✓] Connected device (3 available) ! Error: iPhone is busy: Fetching debug symbols for iPhone. Xcode will continue when iPhone is finished. (code -10) ! Error: iPhone di Simone is busy: Fetching debug symbols for iPhone di Simone. Xcode will continue when iPhone di Simone is finished. (code -10) [✓] HTTP Host Availability ! Doctor found issues in 1 category. ```

Flutter dependencies

Click To Expand ``` Dart SDK 2.16.0 Flutter SDK 2.10.0 toduba2 2.0.70+22275857 dependencies: - async 2.8.2 [collection meta] - auto_size_text 3.0.0 [flutter] - awesome_notifications 0.6.21 [flutter platform intl] - bottom_navy_bar 6.0.0 [flutter] - cached_network_image 3.2.0 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - cloud_firestore 3.1.7 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - connectivity_plus 2.2.0 [flutter connectivity_plus_platform_interface connectivity_plus_linux connectivity_plus_macos connectivity_plus_web connectivity_plus_windows] - dotted_border 2.0.0+2 [flutter path_drawing] - emojis 0.9.9 [collection] - file_picker 4.3.3 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path] - firebase_analytics 9.1.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_core 1.12.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.5.1 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 11.2.6 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_performance 0.8.0+5 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter] - firebase_remote_config 2.0.0 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter] - flash 2.0.3+2 [flutter] - flow_builder 0.0.6 [flutter] - flutter 0.0.0 [characters collection material_color_utilities meta typed_data vector_math sky_engine] - flutter_bloc 8.0.1 [flutter bloc provider] - flutter_launcher_icons 0.9.2 [args image path yaml] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path typed_data vector_math] - flutter_map 0.14.0 [async collection flutter http intl latlong2 meta positioned_tap_detector_2 proj4dart transparent_image tuple vector_math] - flutter_map_location_marker 3.0.1 [flutter flutter_compass flutter_map geolocator latlong2] - flutter_map_marker_cluster 0.4.4 [flutter flutter_map latlong2 flutter_map_marker_popup] - flutter_phone_direct_caller 2.1.0 [flutter] - flutter_share 2.0.0 [flutter] - flutter_svg 1.0.3 [flutter meta path_drawing vector_math xml] - flutter_svg_provider 1.0.2 [flutter http flutter_svg] - fluttertoast 8.0.8 [flutter flutter_web_plugins] - freezed_annotation 1.1.0 [collection json_annotation meta] - get 4.6.1 [flutter] - http 0.13.4 [async http_parser meta path] - huawei_push 6.1.0+300 [flutter] - image_picker 0.8.4+7 [flutter flutter_plugin_android_lifecycle image_picker_for_web image_picker_platform_interface] - intl 0.17.0 [clock path] - just_audio 0.9.19 [just_audio_platform_interface just_audio_web audio_session rxdart path path_provider async uuid crypto meta flutter] - latlong2 0.8.1 [intl] - local_auth 1.1.10 [flutter flutter_plugin_android_lifecycle intl platform] - logger 1.1.0 - maps_launcher 2.0.1 [flutter flutter_web_plugins url_launcher] - ms_status 0.0.1 [flutter lint] - mutex 3.0.0 - open_file 3.2.1 [flutter ffi] - path_provider 2.0.8 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - permission_handler 8.3.0 [flutter meta permission_handler_platform_interface] - phone_number 0.12.0+1 [flutter meta] - pinput 1.2.2 [flutter] - pretty_qr_code 2.0.2 [flutter qr] - qr_code_scanner 0.6.1 [js flutter flutter_web_plugins] - share 2.0.4 [meta mime flutter] - share_plus 3.0.4 [meta mime flutter share_plus_platform_interface share_plus_linux share_plus_macos share_plus_windows share_plus_web] - shared_preferences 2.0.13 [flutter shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - store_redirect 2.0.1 [flutter] - stripe_sdk 5.0.0-nullsafety.1 [flutter http url_launcher mask_text_input_formatter flutter_slidable simple_animations supercharged awesome_card credit_card_validator collection webview_flutter universal_html] - styled_text 3.0.5+1 [flutter xmlstream] - syncfusion_flutter_pdf 19.4.50-beta [flutter intl xml syncfusion_flutter_core crypto convert] - uni_links 0.5.1 [flutter uni_links_platform_interface uni_links_web] - url_launcher 6.0.18 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - utilities 0.0.1 [async auto_size_text cached_network_image crypto device_info image_picker image_cropper flutter flutter_image_compress flutter_map flutter_secure_storage flutter_svg fluttertoast geolocator get latlong2 mutex package_info pointycastle shared_preferences lint logger path_provider freezed_annotation] - webview_flutter 2.8.0 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview] dev dependencies: - build_runner 2.1.7 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - dart_code_metrics 4.10.1 [analyzer analyzer_plugin ansicolor args collection crypto file glob html meta path source_span yaml] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph typed_data] - freezed 1.1.1 [analyzer build build_config collection meta source_gen freezed_annotation] - lint 1.8.2 - mockito 5.0.17 [analyzer build code_builder collection dart_style matcher meta path source_gen test_api] transitive dependencies: - _fe_analyzer_shared 34.0.0 [meta] - analyzer 3.2.0 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - analyzer_plugin 0.9.0 [analyzer collection dart_style pub_semver yaml] - animated_stack_widget 0.0.4 [flutter] - ansicolor 2.0.1 - archive 3.1.11 [crypto path] - args 2.3.0 - audio_session 0.1.6+1 [flutter flutter_web_plugins rxdart meta] - awesome_card 1.1.7 [flutter] - bloc 8.0.2 [meta] - boolean_selector 2.1.0 [source_span string_scanner] - build 2.2.1 [analyzer async convert crypto glob logging meta path] - build_config 1.0.0 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 3.0.1 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.6 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.3 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.1.4 [built_collection collection fixnum meta] - cached_network_image_platform_interface 1.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.0.1 [flutter flutter_cache_manager cached_network_image_platform_interface] - characters 1.2.0 - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - cli_util 0.3.5 [meta path] - clock 1.1.0 - cloud_firestore_platform_interface 5.4.12 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.6.7 [cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.1.0 [built_collection built_value collection matcher meta] - collection 1.15.0 - connectivity_plus_linux 1.2.0 [flutter connectivity_plus_platform_interface meta nm] - connectivity_plus_macos 1.2.1 [connectivity_plus_platform_interface flutter] - connectivity_plus_platform_interface 1.2.0 [flutter meta plugin_platform_interface] - connectivity_plus_web 1.2.0 [connectivity_plus_platform_interface flutter_web_plugins flutter] - connectivity_plus_windows 1.2.0 [connectivity_plus_platform_interface flutter] - convert 3.0.1 [typed_data] - credit_card_type_detector 2.0.0 - credit_card_validator 2.0.1 [credit_card_type_detector] - cross_file 0.3.2 [flutter js meta] - crypto 3.0.1 [collection typed_data] - csslib 0.17.1 [source_span] - dart_style 2.2.1 [analyzer args path pub_semver source_span] - dbus 0.6.8 [args ffi meta xml] - device_info 2.0.3 [flutter device_info_platform_interface] - 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] - firebase 9.0.2 [http http_parser js] - firebase_analytics_platform_interface 3.0.5 [firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.4.0+6 [firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_core_platform_interface 4.2.4 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.5.4 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.1.13 [collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 3.1.6 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.2.7 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_performance_platform_interface 0.1.0+5 [firebase_core flutter plugin_platform_interface] - firebase_performance_web 0.1.0+5 [firebase firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins js] - firebase_remote_config_platform_interface 1.0.5 [firebase_core flutter meta plugin_platform_interface] - firebase_remote_config_web 1.0.5 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins js] - fixnum 1.0.0 - flutter_blurhash 0.6.0 [flutter meta pedantic] - flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_compass 0.7.0 [flutter] - flutter_image_compress 1.1.0 [flutter] - flutter_lints 1.0.4 [lints] - flutter_map_marker_popup 2.1.1 [flutter flutter_map latlong2 animated_stack_widget] - flutter_plugin_android_lifecycle 2.0.5 [flutter] - flutter_secure_storage 5.0.2 [meta flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows] - flutter_secure_storage_linux 1.1.0 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_macos 1.1.0 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_platform_interface 1.0.0 [flutter plugin_platform_interface] - flutter_secure_storage_web 1.0.2 [flutter flutter_web_plugins flutter_secure_storage_platform_interface js] - flutter_secure_storage_windows 1.1.2 [flutter flutter_secure_storage_platform_interface] - flutter_slidable 0.6.0 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta typed_data vector_math] - frontend_server_client 2.1.2 [async path] - geolocator 8.1.1 [flutter geolocator_platform_interface geolocator_android geolocator_apple geolocator_web geolocator_windows] - geolocator_android 3.0.2 [flutter geolocator_platform_interface] - geolocator_apple 2.0.1 [flutter geolocator_platform_interface] - geolocator_platform_interface 4.0.2 [flutter plugin_platform_interface vector_math meta] - geolocator_web 2.1.4 [flutter flutter_web_plugins geolocator_platform_interface] - geolocator_windows 0.1.0 [flutter geolocator_platform_interface] - glob 2.0.2 [async collection file path string_scanner] - graphs 2.1.0 [collection] - html 0.15.0 [csslib source_span] - http_multi_server 3.0.1 [async] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image 3.1.1 [archive meta xml] - image_cropper 1.4.1 [flutter] - image_picker_for_web 2.1.5 [flutter flutter_web_plugins image_picker_platform_interface pedantic] - image_picker_platform_interface 2.4.3 [flutter http plugin_platform_interface cross_file] - io 1.0.3 [meta path string_scanner] - js 0.6.3 - json_annotation 4.4.0 [meta] - just_audio_platform_interface 4.1.0 [flutter plugin_platform_interface] - just_audio_web 0.4.4 [just_audio_platform_interface flutter flutter_web_plugins] - lints 1.0.1 - lists 1.0.1 [meta] - logging 1.0.2 - mask_text_input_formatter 2.1.0 [flutter] - matcher 0.12.11 [stack_trace] - material_color_utilities 0.1.3 - meta 1.7.0 - mgrs_dart 2.0.0 [unicode] - mime 1.0.1 - nested 1.0.0 [flutter] - nm 0.4.4 [dbus] - octo_image 1.0.1 [flutter flutter_blurhash] - package_config 2.0.2 [path] - package_info 2.0.2 [flutter] - path 1.8.0 - path_drawing 1.0.0 [vector_math meta path_parsing flutter] - path_parsing 1.0.0 [vector_math meta] - path_provider_android 2.0.11 [flutter path_provider_platform_interface] - path_provider_ios 2.0.7 [flutter path_provider_platform_interface] - path_provider_linux 2.1.5 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.5 [flutter path_provider_platform_interface] - path_provider_platform_interface 2.0.3 [flutter platform plugin_platform_interface] - path_provider_windows 2.0.5 [ffi flutter path path_provider_platform_interface win32] - pedantic 1.11.1 - permission_handler_platform_interface 3.7.0 [flutter meta plugin_platform_interface] - petitparser 4.4.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.1.2 [meta] - pointycastle 3.5.1 [collection convert js] - pool 1.5.0 [async stack_trace] - positioned_tap_detector_2 1.0.4 [flutter] - process 4.2.4 [file path platform] - proj4dart 2.0.0 [mgrs_dart wkt_parser meta] - provider 6.0.2 [collection flutter nested] - pub_semver 2.1.0 [collection meta] - pubspec_parse 1.2.0 [checked_yaml collection json_annotation pub_semver yaml] - qr 2.1.0 [meta] - quiver 3.0.1+1 [matcher] - rxdart 0.27.3 - share_plus_linux 2.0.4 [share_plus_platform_interface file flutter meta url_launcher] - share_plus_macos 2.0.2 [share_plus_platform_interface flutter] - share_plus_platform_interface 2.0.1 [flutter meta mime plugin_platform_interface] - share_plus_web 2.0.4 [share_plus_platform_interface url_launcher flutter flutter_web_plugins meta] - share_plus_windows 2.0.3 [share_plus_platform_interface flutter meta url_launcher] - shared_preferences_android 2.0.10 [flutter shared_preferences_platform_interface] - shared_preferences_ios 2.0.9 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.0.4 [file 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.3 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.0.4 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.2.0 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.1 [shelf stream_channel web_socket_channel] - simple_animations 3.2.0 [flutter supercharged flutter_lints] - sky_engine 0.0.99 - source_gen 1.2.1 [analyzer async build dart_style glob meta path source_span yaml] - source_span 1.8.1 [collection path term_glyph] - sqflite 2.0.2 [flutter sqflite_common path] - sqflite_common 2.2.0 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.0 [charcode source_span] - supercharged 2.1.1 [supercharged_dart flutter] - supercharged_dart 2.1.1 - syncfusion_flutter_core 19.4.50 [vector_math flutter] - synchronized 3.0.0 - term_glyph 1.2.0 - test_api 0.4.8 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timing 1.0.0 [json_annotation] - transparent_image 2.0.0 - tuple 2.0.0 [quiver] - typed_data 1.3.0 [collection] - uni_links_platform_interface 1.0.0 [flutter plugin_platform_interface] - uni_links_web 0.1.0 [flutter flutter_web_plugins uni_links_platform_interface] - unicode 0.3.1 [lists] - universal_html 2.0.8 [async csslib charcode collection html meta source_span typed_data universal_io] - universal_io 2.0.4 [collection crypto meta typed_data] - url_launcher_android 6.0.15 [flutter url_launcher_platform_interface] - url_launcher_ios 6.0.15 [flutter url_launcher_platform_interface] - url_launcher_linux 2.0.3 [flutter] - url_launcher_macos 2.0.3 [flutter] - url_launcher_platform_interface 2.0.5 [flutter plugin_platform_interface] - url_launcher_web 2.0.8 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 2.0.3 [flutter url_launcher_platform_interface] - uuid 3.0.5 [crypto] - vector_math 2.1.1 - watcher 1.0.1 [async path] - web_socket_channel 2.1.0 [async crypto stream_channel] - webview_flutter_android 2.8.2 [flutter webview_flutter_platform_interface] - webview_flutter_platform_interface 1.8.1 [flutter plugin_platform_interface] - webview_flutter_wkwebview 2.7.1 [flutter webview_flutter_platform_interface] - win32 2.3.11 [ffi] - wkt_parser 2.0.0 - xdg_directories 0.2.0+1 [meta path process] - xml 5.3.1 [collection meta petitparser] - xmlstream 1.0.0 - yaml 3.1.0 [collection source_span string_scanner] ```

darshankawar commented 2 years ago

@smsimone I think you are hitting https://github.com/FirebaseExtended/flutterfire/discussions/5636 in which we need to improve the internal typing so that the null check isn't triggered. Please follow-up in the discussion thread for further updates. Closing this as a duplicate.