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] Crash on iOS with "flutter_local_notifications" like was before #10610

Closed robkawaev closed 1 year ago

robkawaev commented 1 year ago

Bug report

Describe the bug The same problem was here: https://github.com/firebase/flutterfire/issues/4026 Stacked on notification and crash.

Crash on:

XCode error: EXC_BAD_ACCESS

AppDelegate.swift

import UIKit
import Flutter
import FirebaseCore
import flutter_local_notifications

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    FirebaseApp.configure()
    if #available(iOS 10.0, *) {
       UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
    }
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Crash apears after add this code from "flutter_local_notifications":

if #available(iOS 10.0, *) {
       UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
}

Without this code onSelectNotification for local notification doesn't work!


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [!] Flutter (Channel unknown, 3.3.5, on Microsoft Windows [Version 10.0.19045.2006], locale ru-RU) ! Flutter version 3.3.5 on channel unknown at C:\Users\robert\sdk\flutter ! Upstream repository unknown ā€¢ Framework revision d9111f6402 (5 months ago), 2022-10-19 12:27:13 -0700 ā€¢ Engine revision 3ad69d7be3 ā€¢ Dart version 2.18.2 ā€¢ DevTools version 2.15.0 [āˆš] Android toolchain - develop for Android devices (Android SDK version 33.0.2) ā€¢ Android SDK at C:\Users\robert\AppData\Local\Android\sdk ā€¢ Platform android-33-ext4, build-tools 33.0.2 ā€¢ Java binary at: C:\Program Files\BellSoft\LibericaJDK-11\bin\java ā€¢ Java version OpenJDK Runtime Environment (build 11.0.18+10-LTS) ā€¢ All Android licenses accepted. [āˆš] Chrome - develop for the web ā€¢ Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [X] Visual Studio - develop for Windows X Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [!] Android Studio (version 2022.1) ā€¢ Android Studio at C:\Program Files\Android\Android Studio ā€¢ 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 X Unable to find bundled Java version. ā€¢ Try updating or re-installing Android Studio. [āˆš] VS Code (version 1.76.1) ā€¢ VS Code at C:\Users\robert\AppData\Local\Programs\Microsoft VS Code ā€¢ Flutter extension version 3.60.0 [āˆš] Connected device (3 available) ā€¢ Windows (desktop) ā€¢ windows ā€¢ windows-x64 ā€¢ Microsoft Windows [Version 10.0.19045.2006] ā€¢ Chrome (web) ā€¢ chrome ā€¢ web-javascript ā€¢ Google Chrome 111.0.5563.65 ā€¢ Edge (web) ā€¢ edge ā€¢ web-javascript ā€¢ Microsoft Edge 110.0.1587.57 [āˆš] HTTP Host Availability ā€¢ All required HTTP hosts are available ! Doctor found issues in 3 categories. ```

Flutter dependencies

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

Click To Expand ``` dependencies: - animations 2.0.5 [flutter] - app_settings 4.2.0 [flutter] - appmetrica_plugin 1.1.0 [flutter stack_trace logging decimal] - appmetrica_push_plugin 0.2.0 [flutter appmetrica_plugin] - auto_route 5.0.4 [flutter path collection meta] - auto_size_text 3.0.0 [flutter] - cloud_firestore 4.2.0 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cupertino_icons 1.0.4 - dartz 0.10.1 - device_info_plus 8.0.0 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32] - dio 4.0.6 [http_parser path] - equatable 2.0.5 [collection meta] - firebase_analytics 10.1.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_core 2.7.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.0.7 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 14.2.6 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] - flutter_bloc 8.0.1 [flutter bloc provider] - flutter_local_notifications 13.0.0 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math] - flutter_native_splash 2.2.9 [args flutter flutter_web_plugins html image js lint meta path universal_io xml yaml] - flutter_native_timezone 2.0.0 [flutter_web_plugins flutter js] - flutter_svg 1.1.5 [flutter meta path_drawing vector_math xml] - flutter_vibrate 1.3.0 [flutter] - get_it 7.2.0 [async collection] - google_sign_in 5.4.2 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web] - http 0.13.4 [async http_parser meta path] - image_picker 0.8.6 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface] - in_app_review 2.0.6 [flutter in_app_review_platform_interface] - injectable 2.1.0 [get_it] - internet_connection_checker 1.0.0+1 - intl 0.17.0 [clock path] - loader_overlay 2.1.0 [flutter back_button_interceptor] - lottie 1.4.2 [archive flutter path vector_math] - package_info_plus 3.0.2 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - path 1.8.2 - path_provider 2.0.11 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - permission_handler 10.2.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - provider 6.0.2 [collection flutter nested] - rxdart 0.27.7 - share_plus 2.2.0 [meta mime flutter share_plus_platform_interface share_plus_linux share_plus_macos share_plus_windows share_plus_web] - shared_preferences 2.0.12 [flutter shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - sign_in_with_apple 4.2.0 [flutter meta sign_in_with_apple_platform_interface sign_in_with_apple_web] - smooth_page_indicator 1.0.0+2 [flutter] - sqflite 2.2.2 [flutter sqflite_common path] - sqlite_viewer 1.0.5 [flutter json_table path sqflite] - timezone 0.9.1 [path] - transparent_image 2.0.0 - url_launcher 6.1.6 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - uuid 3.0.7 [crypto] - zoom_tap_animation 1.1.0 [flutter] dev dependencies: - auto_route_generator 5.0.2 [build source_gen analyzer path build_runner code_builder dart_style xml args auto_route] - build_runner 2.1.11 [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] - change_app_package_name 1.1.0 - dart_code_metrics 4.19.1 [analyzer analyzer_plugin ansicolor args collection crypto file glob html meta path source_span xml yaml] - dependency_validator 3.2.2 [args build_config checked_yaml glob io json_annotation logging package_config path pub_semver pubspec_parse yaml] - flutter_gen_runner 5.1.0+1 [flutter_gen_core build collection crypto glob path] - flutter_launcher_icons 0.11.0 [args checked_yaml cli_util image json_annotation path yaml] - flutter_lints 2.0.1 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - hive_generator 1.1.3 [build source_gen hive analyzer source_helper] - injectable_generator 2.1.3 [build source_gen path glob analyzer code_builder dart_style injectable collection recase] transitive dependencies: - _fe_analyzer_shared 47.0.0 [meta] - _flutterfire_internals 1.0.17 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 4.7.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - analyzer_plugin 0.10.0 [analyzer collection dart_style pub_semver yaml] - ansicolor 2.0.1 - archive 3.1.11 [crypto path] - args 2.3.1 - async 2.9.0 [collection meta] - back_button_interceptor 6.0.1 [collection flutter] - bloc 8.0.2 [meta] - boolean_selector 2.1.0 [source_span string_scanner] - build 2.3.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.1.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.10 [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] - characters 1.2.1 - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - cli_util 0.3.5 [meta path] - clock 1.1.1 - cloud_firestore_platform_interface 5.9.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.1.1 [_flutterfire_internals 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.16.0 - color 3.0.0 - convert 3.0.1 [typed_data] - cross_file 0.3.3+2 [js meta] - crypto 3.0.1 [collection typed_data] - csslib 0.17.2 [source_span] - dart_style 2.2.4 [analyzer args path pub_semver source_span] - dartx 1.1.0 [characters collection crypto meta path time] - dbus 0.7.8 [args ffi meta xml] - decimal 2.3.2 [rational] - device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface] - fake_async 1.3.1 [clock collection] - ffi 2.0.1 - file 6.1.2 [meta path] - firebase_analytics_platform_interface 3.3.17 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.1+8 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_core_platform_interface 4.5.3 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.2.2 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.3.8 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 4.2.15 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.2.16 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - fixnum 1.0.0 - flutter_gen_core 5.1.0+1 [path yaml mime xml dartx color collection json_annotation glob dart_style analyzer args pub_semver source_span]- flutter_local_notifications_linux 3.0.0+1 [dbus ffi flutter flutter_local_notifications_platform_interface path xdg_directories] - flutter_local_notifications_platform_interface 6.0.0 [flutter plugin_platform_interface] - flutter_plugin_android_lifecycle 2.0.5 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - frontend_server_client 2.1.2 [async path] - glob 2.0.2 [async collection file path string_scanner] - google_sign_in_android 6.1.4 [flutter google_sign_in_platform_interface] - google_sign_in_ios 5.5.1 [flutter google_sign_in_platform_interface] - google_sign_in_platform_interface 2.3.0 [flutter plugin_platform_interface quiver] - google_sign_in_web 0.10.2 [flutter flutter_web_plugins google_sign_in_platform_interface js] - graphs 2.1.0 [collection] - hive 2.0.5 [meta crypto] - 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.2.0 [archive meta xml] - image_picker_android 0.8.5+3 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 2.1.6 [flutter flutter_web_plugins image_picker_platform_interface] - image_picker_ios 0.8.6+1 [flutter image_picker_platform_interface] - image_picker_platform_interface 2.6.2 [cross_file flutter http plugin_platform_interface] - in_app_review_platform_interface 2.0.4 [flutter url_launcher plugin_platform_interface platform] - io 1.0.3 [meta path string_scanner] - js 0.6.4 - json_annotation 4.7.0 [meta] - json_table 2.0.1 [flutter] - lint 1.10.0 - lints 2.0.1 - logging 1.0.2 - matcher 0.12.12 [stack_trace] - material_color_utilities 0.1.5 - meta 1.8.0 - mime 1.0.3 - nested 1.0.0 [flutter] - package_config 2.0.2 [path] - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [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.7 [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.1.3 [ffi flutter path path_provider_platform_interface win32] - permission_handler_android 10.2.0 [flutter permission_handler_platform_interface] - permission_handler_apple 9.0.7 [flutter permission_handler_platform_interface] - permission_handler_platform_interface 3.9.0 [flutter meta plugin_platform_interface] - permission_handler_windows 0.1.2 [flutter permission_handler_platform_interface] - petitparser 5.0.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.1.3 [meta] - pool 1.5.0 [async stack_trace] - process 4.2.4 [file path platform] - pub_semver 2.1.0 [collection meta] - pubspec_parse 1.2.0 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.1.0 [matcher] - rational 2.2.2 - recase 4.1.0 - share_plus_linux 2.0.4 [share_plus_platform_interface file flutter meta url_launcher] - share_plus_macos 2.1.0 [share_plus_platform_interface flutter] - share_plus_platform_interface 2.1.0 [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] - sign_in_with_apple_platform_interface 1.0.0 [flutter plugin_platform_interface meta] - sign_in_with_apple_web 1.0.1 [flutter flutter_web_plugins sign_in_with_apple_platform_interface js] - sky_engine 0.0.99 - source_gen 1.2.5 [analyzer async build dart_style glob meta path source_span yaml] - source_helper 1.3.3 [analyzer collection source_gen] - source_span 1.9.0 [collection path term_glyph] - sqflite_common 2.4.0+2 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.1 [source_span] - synchronized 3.0.0+3 - term_glyph 1.2.1 - test_api 0.4.12 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - time 2.1.2 [clock] - timing 1.0.0 [json_annotation] - typed_data 1.3.0 [collection] - 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 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.0 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.1 [flutter plugin_platform_interface] - url_launcher_web 2.0.13 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface] - vector_math 2.1.2 - watcher 1.0.1 [async path] - web_socket_channel 2.1.0 [async crypto stream_channel] - win32 3.1.3 [ffi] - xdg_directories 0.2.0+3 [meta path process] - xml 6.1.0 [collection meta petitparser] - yaml 3.1.1 [collection source_span string_scanner] ```

darshankawar commented 1 year ago

@robkawaev Are you getting this crash while data message only ?

Crash apears after add this code from "flutter_local_notifications":

Ideally you don't need to make any changes to AppDelegate.swift. Also, have you disabled method swizzling ? If so, see this documentation for reference.

If above is not relevant or helpful, please provide us reproducible sample that we can use to verify this issue.

google-oss-bot commented 1 year ago

Hey @robkawaev. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 1 year ago

Since there haven't been any recent updates here, I am going to close this issue.

@robkawaev if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.