Describe the bug
FirebaseMessaging.instance.getInitialMessage().notification will be null if the app is open while i'm receive a notification and close it before open the notification.
Steps to reproduce
Steps to reproduce the behavior:
This happen on the android only, iOS work's fine.
Open application and leave it at the background
Notification received
Close the application
if you open the aplication again, the FirebaseMessaging.instance.getInitialMessage().notification will be null
Expected behavior
The message of FirebaseMessaging.instance.getInitialMessage().notification not be null
Sample project
This step is a bit hard to do, because have to do alot of things to make notifications work.
But the functions that make the Firebase initialize are bellow:
`Firebase.initializeApp().whenComplete(() async {
setupInteractedMessage();
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Got a message whilst in the foreground!');
print('Message data: ${message.data}');
if (message.notification != null) {
print(
'Message also contained a notification: ${message.notification}');
String title = message.notification.title;
String body = message.notification.body;
codigoTopico = title.split(":").last;
if (double.parse(codigoTopico, (e) => null) != null) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: Text(title),
content: Text(body),
elevation: 10,
actions: [
ElevatedButton(
onPressed: () {
Navigator.pop(context);
getTopic();
},
child: Text(
'Ver Tópico',
style: TextStyle(fontSize: 20),
),
),
ElevatedButton(
onPressed: () => Navigator.pop(context),
child: Text(
'FECHAR',
style: TextStyle(fontSize: 20),
),
)
],
));
} else {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: Text(title),
content: Text(body),
elevation: 10,
actions: [
ElevatedButton(
onPressed: () => Navigator.pop(context),
child: Text(
'FECHAR',
style: TextStyle(fontSize: 20),
),
)
],
));
}
}
});
setState(() {});
});`
Future<void> setupInteractedMessage() async {
// Get any messages which caused the application to open from
// a terminated state.
RemoteMessage initialMessage =
await FirebaseMessaging.instance.getInitialMessage();
// If the message also contains a data property with a "type" of "chat",
// navigate to a chat screen
if (initialMessage != null) {
_handleMessage(initialMessage);
}
// Also handle any interaction when the app is in the background via a
// Stream listener
FirebaseMessaging.onMessageOpenedApp.listen(_handleMessage);
}
void _handleMessage(RemoteMessage message) {
//print("ABERTO PELA NOTIFICAÇÃO!");
String title = message.notification.title;
codigoTopico = title.split(":").last;
getTopic();
}
Additional context
This happend only on the Android version, on iOS works fine.
ERROR:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: NoSuchMethodError: The getter 'title' was called on null.
Receiver: null
Tried calling: title
Flutter doctor
Run flutter doctor and paste the output below:
Click To Expand
```
[√] Flutter (Channel stable, 3.7.5, on Microsoft Windows [versÆo 10.0.22621.1555], locale pt-BR)
[X] Windows Version (Unable to confirm if installed Windows version is 10 or greater)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[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)
X Unable to find bundled Java version.
[√] Connected device (5 available)
[√] HTTP Host Availability
! Doctor found issues in 4 categories.
```
Flutter dependencies
Run flutter pub deps -- --style=compact and paste the output below:
Bug report
Describe the bug FirebaseMessaging.instance.getInitialMessage().notification will be null if the app is open while i'm receive a notification and close it before open the notification.
Steps to reproduce
Steps to reproduce the behavior:
This happen on the android only, iOS work's fine.
Expected behavior
The message of FirebaseMessaging.instance.getInitialMessage().notification not be null
Sample project
This step is a bit hard to do, because have to do alot of things to make notifications work. But the functions that make the Firebase initialize are bellow:
Additional context
This happend only on the Android version, on iOS works fine.
ERROR:
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` [√] Flutter (Channel stable, 3.7.5, on Microsoft Windows [versÆo 10.0.22621.1555], locale pt-BR) [X] Windows Version (Unable to confirm if installed Windows version is 10 or greater) [!] Android toolchain - develop for Android devices (Android SDK version 33.0.2) X cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. X Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for more details. [√] Chrome - develop for the web [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) X Unable to find bundled Java version. [√] Connected device (5 available) [√] HTTP Host Availability ! Doctor found issues in 4 categories. ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` Dart SDK 2.19.2 Flutter SDK 3.7.5 dependencies: - after_layout 1.2.0 [flutter] - cached_network_image 3.2.3 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - cupertino_icons 1.0.5 - date_format 2.0.7 - device_info_plus 8.1.0 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32] - firebase_core 1.24.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_core_platform_interface 4.5.1 [collection flutter flutter_test meta plugin_platform_interface] - firebase_messaging 11.4.4 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine] - flutter_datetime_picker 1.5.1 [flutter] - 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_local_notifications 8.1.1+1 [flutter flutter_local_notifications_platform_interface platform timezone] - fluttertoast 8.2.1 [flutter flutter_web_plugins] - html 0.15.1 [csslib source_span] - http 0.13.5 [async http_parser meta path] - image_picker 0.8.6+4 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface] - intl 0.17.0 [clock path] - modal_progress_hud 0.1.3 [flutter] - package_info_plus 1.4.3+1 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web] - permission_handler 10.2.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - shared_preferences 2.0.18 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - timezone 0.7.0 [path] - uni_links 0.5.1 [flutter uni_links_platform_interface uni_links_web] - url_launcher 6.1.10 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] dev dependencies: - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] dependency overrides: - image_picker_android 0.8.4+13 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] transitive dependencies: - async 2.10.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - cached_network_image_platform_interface 2.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.0.2 [flutter flutter_cache_manager cached_network_image_platform_interface] - characters 1.2.1 - chewie 1.4.0 [cupertino_icons flutter provider video_player wakelock] - chewie_audio 1.3.0 [cupertino_icons flutter video_player] - clock 1.1.1 - collection 1.17.0 - cross_file 0.3.3+4 [js meta] - crypto 3.0.2 [typed_data] - csslib 0.17.2 [source_span] - 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.4 [meta path] - firebase_core_web 1.7.3 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_messaging_platform_interface 3.5.4 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.4.4 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - flutter_blurhash 0.7.0 [flutter] - flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_layout_grid 1.0.6 [flutter collection meta quiver] - flutter_local_notifications_platform_interface 4.0.1 [flutter plugin_platform_interface] - flutter_math_fork 0.5.0 [flutter flutter_svg provider meta collection tuple] - flutter_plugin_android_lifecycle 2.0.8 [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 vector_math] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image_picker_for_web 2.1.11 [flutter flutter_web_plugins image_picker_platform_interface] - image_picker_ios 0.8.7 [flutter image_picker_platform_interface] - image_picker_platform_interface 2.6.3 [cross_file flutter http plugin_platform_interface] - js 0.6.5 [meta] - matcher 0.12.13 [meta stack_trace] - material_color_utilities 0.2.0 - meta 1.8.0 - nested 1.0.0 [flutter] - numerus 1.1.1 - octo_image 1.0.2 [flutter flutter_blurhash] - package_info_plus_linux 1.0.5 [package_info_plus_platform_interface flutter path] - package_info_plus_macos 1.3.0 [flutter] - package_info_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface] - package_info_plus_web 1.0.6 [flutter flutter_web_plugins http meta package_info_plus_platform_interface] - package_info_plus_windows 2.1.0 [package_info_plus_platform_interface ffi flutter win32] - path 1.8.2 - path_drawing 0.5.1+1 [vector_math meta path_parsing flutter] - path_parsing 0.2.1 [vector_math meta] - path_provider 2.0.13 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - path_provider_android 2.0.23 [flutter path_provider_platform_interface] - path_provider_foundation 2.1.2 [flutter path_provider_platform_interface] - path_provider_linux 2.1.9 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.0.6 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.4 [ffi flutter path path_provider_platform_interface win32] - pedantic 1.11.1 - 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.1.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.1.4 [meta] - process 4.2.4 [file path platform] - provider 6.0.5 [collection flutter nested] - quiver 3.2.1 [matcher] - rxdart 0.27.7 - shared_preferences_android 2.0.16 [flutter shared_preferences_platform_interface] - shared_preferences_foundation 2.1.4 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.1.4 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_platform_interface 2.1.1 [flutter plugin_platform_interface] - shared_preferences_web 2.0.5 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.1.4 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - sky_engine 0.0.99 - source_span 1.9.1 [collection path term_glyph] - sqflite 2.2.5 [flutter sqflite_common path] - sqflite_common 2.4.2+2 [synchronized path meta] - stack_trace 1.11.0 [path] - stream_channel 2.1.1 [async] - string_scanner 1.2.0 [source_span] - synchronized 3.0.1 - term_glyph 1.2.1 - test_api 0.4.16 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - tuple 2.0.1 - typed_data 1.3.1 [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] - url_launcher_android 6.0.24 [flutter url_launcher_platform_interface] - url_launcher_ios 6.1.1 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.3 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.3 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.2 [flutter plugin_platform_interface] - 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.1 [flutter wakelock_platform_interface win32] - webview_flutter 2.8.0 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview] - webview_flutter_android 2.10.4 [flutter webview_flutter_platform_interface] - webview_flutter_platform_interface 1.9.5 [flutter meta plugin_platform_interface] - webview_flutter_wkwebview 2.9.5 [flutter path webview_flutter_platform_interface] - win32 3.1.3 [ffi] - xdg_directories 1.0.0 [meta path process] - xml 5.4.1 [collection meta petitparser] ```