Description
Bug report
Describe the bug
The onMessage
handler is no longer called for data messages on iOS in the foreground. It is called for data messages on Android in the foreground, and it is called for display messages on iOS in the foreground.
Steps to reproduce
Steps to reproduce the behavior:
- Set up
onMessage
handler in the app - Send a simple data message to an iOS registration token
- ... Wait
- See it never get called
Expected behavior
I would expect the onMessage
handler to be called for data messages in the foreground. This is supposed to be the simple scenario. This used to work.
Additional context
I have tried different data messages to see if my format is the culprit, to see if something's changed. To no avail (and note that they still work fine for Android).
Here is what I would normally send (no longer works - just iOS in foreground though):
{
"data": {
"type": "friend-request:cancelled",
"action": "deleted",
"collection": "incoming-friend-requests",
"userId": "tr5EajFZpubvNypZxAGc3SnykWc2"
},
"android": {
"priority": "normal"
}
}
(EDIT) I just saw this pop up in XCode whenever I would send a data message and I could not figure out how it's related but I suppose it must be.
2020-10-01 15:58:24.788526+0100 Runner[972:925222] Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.
I figured this was related to these lines in AppDelegate.swift
.
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
Yet when I removed these, I no longer received display messages (notifications) in the foreground either. So those lines are working.. but only for display messages. Something is holding back my data messages.
I have also tried to add content_available
to aps
but no luck.
The fact that it's worked before and I do still get display messages (notifications) in the onMessage
handler with the app open in the foreground makes me think it can't be a configuration issue on my part.
Flutter doctor
Run flutter doctor
and paste the output below:
Click To Expand
[✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale en-GB)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.49.1)
[!] Connected device
Flutter dependencies
Run flutter pub deps -- --style=compact
and paste the output below:
Click To Expand
Dart SDK 2.9.2
Flutter SDK 1.20.4
dependencies:
- apple_sign_in 0.1.0 [flutter]
- auto_size_text 2.1.0 [flutter]
- cached_network_image 2.3.2+1 [flutter flutter_cache_manager octo_image]
- cupertino_icons 1.0.0
- dio 3.0.10 [http_parser path]
- dio_retry 0.1.9-beta [meta logging dio]
- equatable 1.2.5 [collection meta]
- firebase_analytics 6.0.0 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface]
- firebase_auth 0.18.0+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.5.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_dynamic_links 0.6.0 [flutter firebase_core]
- firebase_messaging 7.0.0 [meta platform flutter firebase_core]
- firebase_remote_config 0.4.0 [flutter firebase_core]
- flare_splash_screen 3.0.1 [flare_loading flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_facebook_login 3.0.0 [flutter collection]
- flutter_linkify 3.1.3 [flutter linkify]
- flutter_markdown 0.4.4 [flutter markdown meta path]
- flutter_native_timezone 1.0.4 [flutter]
- flutter_portal 0.1.0 [flutter]
- flutter_signin_button 1.1.0 [flutter font_awesome_flutter]
- flutter_speed_dial 1.2.5 [flutter]
- font_awesome_flutter 8.8.1 [flutter]
- google_maps_flutter 0.5.32 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface]
- google_sign_in 4.5.3 [google_sign_in_platform_interface flutter meta google_sign_in_web]
- horizontal_blocked_scroll_physics 3.0.0 [flutter pedantic]
- image_cropper 1.3.1 [flutter]
- image_picker 0.6.7+7 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- in_app_update 1.1.11 [flutter]
- intl 0.16.1 [path]
- introduction_screen 1.0.9 [flutter dots_indicator]
- jiffy 3.0.1 [intl]
- location 3.0.2 [flutter meta location_platform_interface location_web]
- maps_launcher 1.2.2+1 [flutter flutter_web_plugins url_launcher]
- open_appstore 1.0.2 [flutter]
- package_info 0.4.3 [flutter]
- provider 4.3.2+2 [flutter nested collection]
- pub_semver 1.4.4 [collection]
- pull_to_refresh 1.6.1 [flutter]
- quiver 2.1.3 [matcher meta]
- rxdart 0.24.1
- share 0.6.5 [meta mime flutter]
- shared_preferences 0.5.10 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web]
- stream_chat_flutter 0.2.8+2 [flutter photo_view rxdart jiffy flutter_portal cached_network_image flutter_markdown url_launcher video_player chewie file_picker image_picker flutter_keyboard_visibility stream_chat mime visibility_detector http_parser]
- url_launcher 5.6.0 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- validators 2.0.1 [vin_decoder]
- visibility_detector 0.1.5 [flutter]
- workmanager 0.2.3 [flutter]
dev dependencies:
- cider 0.0.5 [args change intl markdown marker maybe_just_nothing path pub_semver version_manipulation yaml yaml_edit]
- flutter_driver 0.0.0 [file json_rpc_2 meta path web_socket_channel vm_service_client webdriver flutter flutter_test fuchsia_remote_debug_protocol archive args async boolean_selector characters charcode clock collection convert crypto fake_async intl matcher platform process pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math]
- 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]
- mockito 4.1.1 [collection matcher meta test_api]
- screenshots 2.1.1 [args yaml resource path file archive platform process meta intl tool_mobile]
- test 1.15.2 [analyzer async boolean_selector coverage http http_multi_server io js node_preamble package_config path pedantic pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core]
transitive dependencies:
- _fe_analyzer_shared 7.0.0 [meta]
- analyzer 0.39.17 [_fe_analyzer_shared args charcode cli_util collection convert crypto glob html meta package_config path pub_semver source_span watcher yaml]
- archive 2.0.13 [crypto args path]
- args 1.6.0
- asn1lib 0.6.5
- async 2.4.2 [collection]
- basic_utils 2.6.2 [http logging json_annotation pointycastle asn1lib convert crypto]
- boolean_selector 2.0.0 [source_span string_scanner]
- change 0.1.0 [markdown marker maybe_just_nothing pub_semver]
- characters 1.0.0
- charcode 1.1.3
- chewie 0.9.10 [open_iconic_flutter video_player wakelock flutter]
- cli_util 0.2.0 [path]
- clock 1.0.1 [meta]
- collection 1.14.13
- convert 2.1.1 [charcode typed_data]
- coverage 0.14.1 [args logging package_config path source_maps stack_trace vm_service]
- crypto 2.1.5 [collection convert typed_data]
- csslib 0.16.2 [source_span]
- dots_indicator 1.2.0 [flutter]
- fake_async 1.1.0 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- file_picker 2.0.6 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface]
- firebase 7.3.0 [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_auth_platform_interface 2.0.1 [flutter meta firebase_core plugin_platform_interface]
- firebase_auth_web 0.3.0+1 [flutter flutter_web_plugins firebase meta http_parser intl firebase_core firebase_auth_platform_interface js]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.0 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flare_dart 2.3.4
- flare_flutter 2.0.6 [flutter flare_dart meta]
- flare_loading 2.1.1 [flare_flutter flutter]
- flutter_blurhash 0.5.0 [flutter meta]
- flutter_cache_manager 1.4.2 [flutter path_provider uuid http path sqflite pedantic clock file rxdart]
- flutter_keyboard_visibility 3.2.2 [flutter]
- flutter_plugin_android_lifecycle 1.0.9 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- fuchsia_remote_debug_protocol 0.0.0 [json_rpc_2 process web_socket_channel flutter_test flutter_driver archive args async boolean_selector charcode clock collection convert crypto fake_async file intl matcher meta path platform pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math vm_service_client webdriver]
- glob 1.2.0 [async collection node_io path pedantic string_scanner]
- google_maps_flutter_platform_interface 1.0.4 [flutter meta plugin_platform_interface stream_transform]
- google_sign_in_platform_interface 1.1.2 [flutter meta quiver]
- google_sign_in_web 0.9.2 [google_sign_in_platform_interface flutter flutter_web_plugins meta js]
- html 0.14.0+3 [csslib source_span]
- http 0.12.2 [http_parser path pedantic]
- http_multi_server 2.2.0 [async]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image_picker_platform_interface 1.1.0 [flutter meta http plugin_platform_interface]
- io 0.3.4 [charcode meta path string_scanner]
- js 0.6.2
- json_annotation 3.0.1
- json_rpc_2 2.2.1 [stack_trace stream_channel]
- linkify 2.1.0
- 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]
- logging 0.11.4
- markdown 2.1.8 [args charcode meta]
- marker 0.1.0 [markdown]
- matcher 0.12.8 [stack_trace]
- maybe_just_nothing 0.3.1
- meta 1.1.8
- mime 0.9.7
- moor 3.3.1 [meta convert collection synchronized pedantic sqlite3]
- nested 0.0.4 [flutter]
- node_interop 1.1.1 [js]
- node_io 1.1.1 [node_interop path]
- node_preamble 1.4.12
- octo_image 0.3.0 [flutter flutter_blurhash]
- open_iconic_flutter 0.3.0 [flutter]
- package_config 1.9.3 [path charcode]
- path 1.7.0
- path_provider 1.6.14 [flutter path_provider_platform_interface path_provider_macos path_provider_linux]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+3 [flutter]
- path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface]
- pedantic 1.9.0
- photo_view 0.10.2 [flutter]
- platform 2.2.1
- platform_detect 1.4.0 [meta pub_semver]
- plugin_platform_interface 1.0.2 [meta]
- pointycastle 1.0.2
- pool 1.4.0 [async stack_trace]
- process 3.0.13 [file intl meta path platform]
- pub_cache 0.2.3 [path pub_semver yaml]
- random_string 2.1.0
- resource 2.1.7 [typed_data]
- 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]
- shelf 0.7.9 [async collection http_parser path stack_trace stream_channel]
- shelf_packages_handler 2.0.0 [path shelf shelf_static]
- shelf_static 0.2.8 [convert http_parser mime path shelf]
- shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel]
- sky_engine 0.0.99
- source_map_stack_trace 2.0.0 [path stack_trace source_maps]
- source_maps 0.10.9 [source_span]
- source_span 1.7.0 [charcode collection meta path term_glyph]
- sqflite 1.3.1+1 [flutter sqflite_common path]
- sqflite_common 1.0.2+1 [synchronized path meta]
- sqlite3 0.1.5 [collection ffi meta]
- sqlite3_flutter_libs 0.2.0
- stack_trace 1.9.5 [path]
- stream_channel 2.0.0 [async]
- stream_chat 0.2.5+1 [flutter json_annotation shared_preferences logging dio web_socket_channel uuid async stream_channel moor path_provider path rxdart collection sqlite3_flutter_libs]
- stream_transform 1.2.0
- string_scanner 1.0.5 [charcode meta source_span]
- sync_http 0.2.0
- synchronized 2.2.0+2
- term_glyph 1.1.0
- test_api 0.2.17 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- test_core 0.3.10 [analyzer async args boolean_selector collection coverage glob io meta package_config path pedantic pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api]
- tool_base 1.9.5+3 [archive file platform process pub_cache]
- tool_mobile 1.9.5+1 [tool_base]
- typed_data 1.2.0 [collection]
- url_launcher_linux 0.0.1+1 [flutter]
- url_launcher_macos 0.0.1+7 [flutter]
- url_launcher_platform_interface 1.0.8 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.3+2 [url_launcher_platform_interface platform_detect flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+1 [flutter]
- uuid 2.2.2 [crypto convert]
- vector_math 2.0.8
- version_manipulation 0.0.5 [pub_semver]
- video_player 0.10.12+2 [meta video_player_platform_interface video_player_web flutter]
- video_player_platform_interface 2.1.1 [flutter meta]
- video_player_web 0.1.3+2 [flutter flutter_web_plugins meta video_player_platform_interface]
- vin_decoder 0.1.2 [meta basic_utils http random_string]
- vm_service 4.2.0 [meta]
- vm_service_client 0.2.6+2 [async collection json_rpc_2 pub_semver source_span stack_trace stream_channel web_socket_channel]
- wakelock 0.1.4+2 [flutter]
- watcher 0.9.7+15 [async path pedantic]
- web_socket_channel 1.1.0 [async crypto stream_channel]
- webdriver 2.1.2 [archive matcher path stack_trace sync_http]
- webkit_inspection_protocol 0.7.3 [logging]
- xdg_directories 0.1.0 [path process flutter]
- yaml 2.2.1 [charcode collection string_scanner source_span]
- yaml_edit 1.0.2 [meta yaml source_span collection]
Activity
TahaTesser commentedon Oct 2, 2020
Hi @rubenvereecken
Pleae try this code sample, no issue son ios with the latest `
flutter doctor -v
code sample
flutter doctor -v
rubenvereecken commentedon Oct 12, 2020
@TahaTesser Thanks for getting back to me and sorry for taking so long to reply. I wanted to dedicate some proper time to this to properly replicate your example. I've now managed and my problem remains - your example doesn't work for me. I do observe the same I did before: the message enters the device, I get some odd message, but it doesn't reach the message handler. The message I get is the following.
I copied your example ad verbatim. I sent messages using the following curl command which was confirmed to work with display messages but not data messages.
My worry is that I set up something else incorrectly but I can't for the life of me think of what else has changed because this definitely used to work. Something I feel insecure about for example is
AppDelegate.swift
, as I mentioned in the initial post. What else can I verify? The APNS config all seems right otherwise I wouldn't be getting display messages.TahaTesser commentedon Oct 14, 2020
Hi @rubenvereecken
The example I used is official example, can you please try in a project on the same firebase account
Using this payload
rubenvereecken commentedon Oct 14, 2020
@TahaTesser That is a display message because it has a notification property and as I said those work fine. This problem is about data messages. Please look at the error message I reported above (I'll replicate it here)
rubenvereecken commentedon Oct 16, 2020
I'm sure the warning message contains some useful indication but I'm not experienced enough with iOS to interpret it.
TahaTesser commentedon Oct 16, 2020
Hi @rubenvereecken
Can you please a complete reproducible minimal code sample in a repository?
Thank you
rubenvereecken commentedon Oct 17, 2020
I now understand this appears to be a duplicate of #3395 which is still open.
TahaTesser commentedon Oct 20, 2020
hI @rubenvereecken
So you have been sending data only messages? As mentioned I tested with a complete payload
Thanks for finding the duplicate
Closing as duplicate of #3395
rubenvereecken commentedon Oct 20, 2020
As per the title, yep.