Closed mohammedHussainSTV closed 2 years ago
@mohammedHussainSTV
Can you provide us the entire crash log ? Also provide us the code for onBackgroundMessage
and how you are handling when you receive the notification and then tap on it, ie, the navigation code as well.
onBackgroundMessage message
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
Future.delayed(Duration(seconds: 2), () {
NotificationUtils.dismissAllNotifications().whenComplete(() {
NotificationUtils.createMessagingNotification(
channelKey: 'chats',
groupKey: 'Test',
chatName: 'Demo',
username: 'userName',
message: 'test',
payload: Map<String, String>.from(message.data));
});
});
}
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
}
Navigation code
Navigator.push(navState.currentContext,
MaterialPageRoute(builder: (context) => Text()));
@mohammedHussainSTV
Can you also provide the entire crash log as requested earlier ? Also provide your onMessageOpenedApp
code too. Are you sending a data-only payload ? Also, try using the plugin official example and use your navigation code snippet in it and see if you still get the same crash or not.
same issue
Logs for issue
`Received an invalid notification content
Received an invalid notification content
Received an invalid notification content
Received an invalid notification content
Received an invalid notification content
2022-01-19 15:23:51.283976+0530 Runner[63198:8106639] flutter: socket receive: type "message", data "2["receiveMessage_61d6e21ade36acc1fb47b5a3",{"message":"👋 hi 👋 👋 👋 👋 👋 👋 👋 👋 hi 👋","message_type":1,"chat_id":"61d6e21ade36acc1fb47b5a3","sender_type":3,"receiver_type":1,"sender_id":"61cc45008012e78699bb3863"}]"
Received an invalid notification content
Received an invalid notification content
Received an invalid notification content
Received an invalid notification content`
onMessageOpenedApp app code
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
String data = jsonEncode(message.data);
handleNotificationClick(data);
// Navigator.pushNamed(context, '/message',
// arguments: MessageArguments(message, true));
});
handleNotificationClick(String dataStr) {
Map<String, dynamic> map = jsonDecode(dataStr);
switch (int.parse(map["notification_type"])) {
case 1:
Navigator.push(navState.currentContext,
MaterialPageRoute(builder: (context) => AccountSetupScreen()));
break;
}}
@mohammedHussainSTV
Since you seem to be also using awesome_notfication
plugin, I doubt if there's any conflict / interference between it and messaging. Can you try the same scenario without using that plugin and see if it helps ?
@darshankawar Issue is resolved now after removing awesome_notfication plugin.
Can you let me know what was the actual issue.
@mohammedHussainSTV You may need to reach out to awesome_notification plugin owner for this. https://github.com/rafaelsetragni/awesome_notifications/issues Closing from here as this isn't a messaging plugin issue.
Bug report
When I receive an remote notification and when I click on notification it calls for navigation to particular screen.Then app crashes
Steps to reproduce
Steps to reproduce the behavior:
Thread 1: EXC_BAD_ACCESS (code=2, address=0x16b20fff8)
Expected behavior
App should have navigated to particular screen by calling
appDidReceiveMessage
Additional context
After debugging I have found that
appDidReceiveMessage
is getting called multiple times.Around 6000 times then it got crashes.Flutter doctor
Click To Expand
``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel master, 2.9.0-1.0.pre.173, on macOS 12.0.1 21A559 darwin-x64, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.1) [✓] Chrome - develop for the web [✓] Android Studio (version 4.2) [✓] VS Code (version 1.63.2) [✓] Connected device (2 available) ! Error: iPhone is not connected. Xcode will continue when iPhone is connected. (code -13) ! Error: iPhone (3) is not connected. Xcode will continue when iPhone (3) is connected. (code -13) [✓] HTTP Host Availability • No issues found! ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` dependencies: - amazon_cognito_identity_dart_2 1.0.3 [convert crypto http] - awesome_notifications 0.6.19 [flutter platform intl] - cached_network_image 3.2.0 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - connectivity 3.0.6 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web] - crypto 3.0.1 [collection typed_data] - cupertino_icons 1.0.4 - device_info 2.0.3 [flutter device_info_platform_interface] - dio 4.0.4 [http_parser path] - equatable 2.0.3 [collection meta] - firebase_analytics 9.0.4 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_core 1.10.6 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.4.4 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_dynamic_links 4.0.3 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_messaging 11.2.5 [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 typed_data vector_math sky_engine] - flutter_facebook_login 3.0.0 [flutter collection] - flutter_html 2.2.1 [html csslib flutter_layout_grid video_player chewie webview_flutter chewie_audio flutter_svg flutter_math_fork collection numerus flutter] - flutter_image_compress 1.1.0 [flutter] - flutter_io_socket 0.0.7 [js] - flutter_local_notifications 9.2.0 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_slidable 0.6.0 [flutter] - fluttertoast 8.0.8 [flutter flutter_web_plugins] - geocoder 0.2.1 [meta flutter] - google_sign_in 5.2.1 [flutter google_sign_in_platform_interface google_sign_in_web meta] - http 0.13.4 [async http_parser meta path] - image_cropper 1.4.1 [flutter] - image_picker 0.8.4+4 [flutter flutter_plugin_android_lifecycle image_picker_for_web image_picker_platform_interface] - intl 0.17.0 [clock path] - json_annotation 4.4.0 [meta] - package_info 2.0.2 [flutter] - 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] - photo_view 0.13.0 [flutter] - pin_code_fields 7.3.0 [flutter] - provider 6.0.2 [collection flutter nested] - rxdart 0.27.3 - shared_preferences 2.0.11 [flutter meta 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 3.3.0 [flutter meta sign_in_with_apple_platform_interface sign_in_with_apple_web] - simple_animations 4.0.1 [flutter flutter_lints collection] - store_redirect 2.0.0 [flutter] - stripe_payment 1.1.4 [flutter] - url_launcher 6.0.17 [flutter meta url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - webview_flutter 2.8.0 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview] dev dependencies: - 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] transitive dependencies: - args 2.3.0 - async 2.8.2 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - 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 - chewie 1.1.0 [cupertino_icons flutter video_player wakelock] - chewie_audio 1.3.0 [cupertino_icons flutter video_player] - clock 1.1.0 - collection 1.15.0 - connectivity_for_web 0.4.0+1 [connectivity_platform_interface flutter_web_plugins flutter] - connectivity_macos 0.2.1+2 [flutter connectivity_platform_interface] - connectivity_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - convert 3.0.1 [typed_data] - cross_file 0.3.2 [flutter js meta] - csslib 0.17.1 [source_span] - dbus 0.6.6 [args ffi meta 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] - firebase_analytics_platform_interface 3.0.3 [firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.4.0+4 [firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_core_platform_interface 4.2.3 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.5.3 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.1.11 [collection firebase_core flutter meta plugin_platform_interface] - firebase_dynamic_links_platform_interface 0.2.0+3 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 3.1.5 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.2.6 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - 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_layout_grid 1.0.3 [flutter collection meta quiver] - flutter_lints 1.0.4 [lints] - flutter_local_notifications_linux 0.4.1+1 [flutter flutter_local_notifications_platform_interface dbus path xdg_directories] - flutter_local_notifications_platform_interface 5.0.0 [flutter plugin_platform_interface] - flutter_math_fork 0.5.0 [flutter flutter_svg provider meta collection tuple] - flutter_plugin_android_lifecycle 2.0.5 [flutter] - flutter_svg 0.23.0+1 [flutter meta path_drawing vector_math xml] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta typed_data vector_math] - google_sign_in_platform_interface 2.1.0 [flutter meta quiver] - google_sign_in_web 0.10.0+3 [flutter flutter_web_plugins google_sign_in_platform_interface js meta] - html 0.15.0 [csslib source_span] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image_picker_for_web 2.1.4 [flutter flutter_web_plugins image_picker_platform_interface meta] - image_picker_platform_interface 2.4.1 [flutter http meta plugin_platform_interface cross_file] - js 0.6.3 - lints 1.0.1 - matcher 0.12.11 [stack_trace] - material_color_utilities 0.1.3 - meta 1.7.0 - nested 1.0.0 [flutter] - numerus 1.1.1 - octo_image 1.0.1 [flutter flutter_blurhash] - path 1.8.0 - path_drawing 0.5.1+1 [vector_math meta path_parsing flutter] - path_parsing 0.2.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.4 [ffi flutter meta path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.4 [flutter meta path_provider_platform_interface] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.4 [ffi flutter meta 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.0 [meta] - process 4.2.4 [file path platform] - quiver 3.0.1+1 [matcher] - shared_preferences_android 2.0.9 [flutter meta shared_preferences_platform_interface] - shared_preferences_ios 2.0.8 [flutter meta shared_preferences_platform_interface] - shared_preferences_linux 2.0.3 [file flutter meta 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.3 [file flutter meta path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - 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_span 1.8.1 [collection path term_glyph] - sqflite 2.0.1 [flutter sqflite_common path] - sqflite_common 2.0.1+1 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.0 [charcode source_span] - 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] - timezone 0.8.0 [path] - tuple 2.0.0 [quiver] - typed_data 1.3.0 [collection] - url_launcher_android 6.0.13 [flutter meta url_launcher_platform_interface] - url_launcher_ios 6.0.13 [flutter meta url_launcher_platform_interface] - url_launcher_linux 2.0.2 [flutter] - url_launcher_macos 2.0.2 [flutter] - url_launcher_platform_interface 2.0.4 [flutter plugin_platform_interface] - url_launcher_web 2.0.5 [flutter flutter_web_plugins meta url_launcher_platform_interface] - url_launcher_windows 2.0.2 [flutter] - uuid 3.0.5 [crypto] - vector_math 2.1.1 - video_player 2.2.10 [flutter meta video_player_platform_interface video_player_web html] - video_player_platform_interface 5.0.0 [flutter plugin_platform_interface] - video_player_web 2.0.5 [flutter flutter_web_plugins meta pedantic video_player_platform_interface] - wakelock 0.5.6 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows] - wakelock_macos 0.4.0 [flutter flutter_web_plugins wakelock_platform_interface] - wakelock_platform_interface 0.3.0 [flutter meta] - wakelock_web 0.4.0 [flutter flutter_web_plugins js wakelock_platform_interface] - wakelock_windows 0.2.0 [flutter wakelock_platform_interface win32] - webview_flutter_android 2.8.2 [flutter webview_flutter_platform_interface] - webview_flutter_platform_interface 1.8.0 [flutter plugin_platform_interface] - webview_flutter_wkwebview 2.7.1 [flutter webview_flutter_platform_interface] - win32 2.3.3 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.3.1 [collection meta petitparser] ```