Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Firebase_messaging] onBackgroundMessage is not called on older iPhone devices. #5988

Closed
shreyansh2211 opened this issue Apr 30, 2021 · 7 comments
Labels
closed-by-bot resolution: no-response Customer did not respond after some time. Stale Issue with no recent activity type: bug Something isn't working

Comments

@shreyansh2211
Copy link

shreyansh2211 commented Apr 30, 2021

We are using firebase_messaging ^9.1.1 in our flutter app. onBackgroundMessage is being called in 'iPhone se' when app is in background or in terminated state. But is in not being called on iPhone 7 or iPhone 8. IOS version is same in all the devices i.e. IOS 14.4.2.

We are calling callkeep: ^0.2.3+1 plugin in onBackgroundMessage. We can't see call UI when app is terminated/in background and receive notification (iPhone 7 or iPhone 8).

This is our code:

void main() async {
FirebaseMessaging.onBackgroundMessage(myBackgroundMessageHandler);

WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
if (!UniversalPlatform.isWeb) {
PushNotificationsManager().initCallKit();
}
Future<dynamic> myBackgroundMessageHandler(RemoteMessage message) async {
await Firebase.initializeApp();
//callkeep: ^0.2.3+1 plugin. code here.
}

Have anyone faced this issue or know how to fix this issue?

Expected behavior

We expect to see call screen as we are able to see on other iPhones like iPhone se and iPhone 11.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.5, on macOS 11.2.2 20D80 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] Connected device (2 available)

• No issues found!


Flutter dependencies

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

Click To Expand
- after_layout 1.1.0 [flutter]
- agora_rtc_engine 3.3.3 [flutter flutter_web_plugins json_annotation]
- animated_floatactionbuttons 0.1.0 [flutter]
- backdrop 0.6.0 [flutter]
- blurrycontainer 0.0.1 [flutter]
- cached_network_image 2.5.1 [flutter flutter_cache_manager octo_image]
- callkeep 0.2.3+1 [flutter]
- cloud_firestore 1.0.4 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta]
- cloud_functions 1.0.3 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter]
- colorize_lumberdash 3.0.0 [lumberdash meta ansicolor]
- country_code_picker 2.0.1 [flutter modal_bottom_sheet collection universal_platform]
- crypto 2.1.5 [collection convert typed_data]
- cupertino_icons 1.0.2
- device_info 2.0.0 [flutter device_info_platform_interface]
- dio 3.0.10 [http_parser path]
- f_logs 1.3.0-alpha-02 [flutter sembast path_provider intl xxtea meta path stack_trace]
- file_picker 3.0.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface]
- firebase_analytics 7.1.1 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta]
- firebase_auth 1.1.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_auth_web 1.0.6 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta]
- firebase_core 1.0.3 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_crashlytics 2.0.0 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- firebase_in_app_messaging 0.4.0+1 [firebase_core flutter meta]
- firebase_messaging 9.1.1 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- firebase_storage 8.0.3 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter]
- flare_flutter 2.0.6 [flutter flare_dart meta]
- flushbar 1.10.4 [flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_app_badger 1.2.0 [flutter]
- flutter_bloc 7.0.0 [flutter bloc provider]
- flutter_cached_pdfview 0.3.5 [flutter flutter_pdfview flutter_cache_manager path_provider path]
- flutter_cupertino_localizations 1.0.1 [flutter flutter_localizations]
- flutter_foreground_plugin 0.4.1 [flutter]
- flutter_image_compress 1.0.0 [flutter]
- flutter_link_preview 1.5.6 [flutter http html gbk2utf8]
- flutter_linkify 5.0.2 [flutter linkify]
- flutter_local_notifications 5.0.0+1 [flutter flutter_local_notifications_platform_interface platform timezone]
- flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math]
- flutter_sms 2.1.1 [flutter url_launcher flutter_web_plugins plugin_platform_interface flutter_user_agent]
- flutter_svg 0.19.3 [flutter meta path_drawing vector_math xml]
- fluttercontactpicker 4.4.0 [flutter contact_picker_platform_interface contact_picker_web]
- fluttertoast 8.0.3 [flutter flutter_web_plugins]
- font_awesome_flutter 9.0.0 [flutter]
- freezed_annotation 0.12.0 [collection json_annotation meta]
- gallery_saver 2.0.3 [flutter path_provider http path]
- geocoder 0.2.1 [meta flutter]
- get_it 6.1.1 [async collection]
- hive 1.4.4+1 [meta crypto]
- hive_flutter 0.3.1 [flutter hive path_provider path]
- http 0.13.1 [http_parser meta path pedantic]
- image_gallery_saver 1.6.9 [flutter]
- image_picker 0.7.4 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface image_picker_for_web]
- injectable 1.2.2 [get_it]
- intl 0.17.0 [clock path]
- json_serializable 3.5.1 [analyzer build build_config json_annotation meta path source_gen]
- location 3.2.4 [flutter location_platform_interface location_web meta]
- lumberdash 3.0.0 [meta]
- material_dialog 0.0.9 [flutter meta]
- native_device_orientation 1.0.0 [flutter meta]
- native_screenshot 1.0.0 [flutter]
- path_provider 1.6.28 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- permission_handler 6.1.1 [flutter meta permission_handler_platform_interface]
- photo_view 0.11.1 [flutter]
- plugin_platform_interface 2.0.0 [meta]
- print_lumberdash 3.0.0 [lumberdash meta]
- provider 5.0.0 [collection flutter nested]
- quiver 3.0.1 [matcher]
- recase 3.0.1
- sentry_flutter 5.0.0 [flutter flutter_web_plugins sentry package_info_plus]
- shake_flutter 10.0.0 [flutter path]
- share 0.6.5+4 [meta mime flutter]
- shared_preferences 0.5.12+4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- sliding_up_panel 1.0.2 [flutter]
- step_progress_indicator 0.2.5+8 [flutter]
- strings 0.2.1 [characters unicode]
- universal_platform 1.0.0-nullsafety
- url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- uuid 2.2.2 [crypto convert]
- validators 2.0.1 [vin_decoder]
- very_good_analysis 2.0.1 [pedantic]
- video_compress 2.1.1 [flutter]
- video_player 2.1.1 [meta video_player_platform_interface video_player_web flutter flutter_test]
- video_thumbnail 0.3.3 [flutter]
- visibility_detector 0.1.5 [flutter]
- wakelock 0.4.0 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web]
- youtube_player_flutter 7.0.0+7 [flutter flutter_inappwebview]

dev dependencies:
- build_runner 1.11.1 [args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style glob graphs http_multi_server io js logging meta mime path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml]
- flutter_driver 0.0.0 [file meta path vm_service webdriver flutter flutter_test fuchsia_remote_debug_protocol archive args async boolean_selector characters charcode clock collection convert crypto fake_async matcher platform process 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]
- freezed 0.12.7 [analyzer build build_config meta source_gen freezed_annotation]
- injectable_generator 1.1.2 [build source_gen path glob analyzer meta code_builder dart_style injectable collection]
- integration_test 1.0.2+2 [flutter flutter_driver flutter_test path vm_service]

dependency overrides:
- flutter_cached_pdfview 0.3.5 [flutter flutter_pdfview flutter_cache_manager path_provider path]
- http 0.13.1 [http_parser meta path pedantic]
- http_parser 4.0.0 [charcode collection source_span string_scanner typed_data]
- intl 0.17.0 [clock path]
- plugin_platform_interface 2.0.0 [meta]
- uuid 2.2.2 [crypto convert]

transitive dependencies:
- _fe_analyzer_shared 12.0.0 [meta]
- analyzer 0.40.6 [_fe_analyzer_shared args cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- ansicolor 2.0.1
- archive 2.0.13 [crypto args path]
- args 1.6.0
- async 2.5.0 [collection]
- basic_utils 2.7.1 [http logging json_annotation pointycastle convert crypto]
- bloc 7.0.0 [meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- build 1.6.2 [analyzer async convert crypto glob logging meta path]
- build_config 0.4.5 [checked_yaml json_annotation meta path pubspec_parse yaml]
- build_daemon 2.1.10 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 1.5.3 [analyzer build crypto graphs logging meta path package_config pool pub_semver]
- build_runner_core 6.1.7 [async build build_config build_resolvers collection convert crypto glob graphs logging meta path package_config pedantic pool timing watcher yaml]
- built_collection 5.0.0
- built_value 8.0.4 [built_collection collection fixnum]
- characters 1.1.0
- charcode 1.2.0
- checked_yaml 1.0.4 [json_annotation source_span yaml]
- cli_util 0.2.0 [path]
- clock 1.1.0
- cloud_firestore_platform_interface 4.0.1 [collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 1.0.4 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- cloud_functions_platform_interface 5.0.1 [firebase_core flutter meta plugin_platform_interface]
- cloud_functions_web 4.0.3 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- code_builder 3.7.0 [built_collection built_value collection matcher meta]
- collection 1.15.0
- contact_picker_platform_interface 4.4.0 [flutter meta plugin_platform_interface]
- contact_picker_web 4.4.0 [flutter flutter_web_plugins js contact_picker_platform_interface]
- convert 2.1.1 [charcode typed_data]
- csslib 0.16.2 [source_span]
- dart_style 1.3.10 [analyzer args path source_span]
- device_info_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- fake_async 1.2.0 [clock collection]
- ffi 1.0.0
- file 6.0.0 [meta path]
- firebase 9.0.1 [http http_parser js]
- firebase_analytics_platform_interface 1.1.0 [flutter meta]
- firebase_analytics_web 0.2.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta]
- firebase_auth_platform_interface 4.1.0 [firebase_core flutter meta plugin_platform_interface]
- firebase_core_platform_interface 4.0.0 [flutter meta plugin_platform_interface]
- firebase_core_web 1.0.2 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_crashlytics_platform_interface 3.0.0 [collection firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_platform_interface 2.1.1 [firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 1.0.4 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- firebase_storage_platform_interface 2.0.1 [collection firebase_core flutter meta plugin_platform_interface]
- firebase_storage_web 1.0.3 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta]
- fixnum 1.0.0
- flare_dart 2.3.4
- flutter_blurhash 0.5.0 [flutter meta]
- flutter_cache_manager 2.1.2 [flutter path_provider uuid http path sqflite pedantic clock file rxdart image]
- flutter_inappwebview 4.0.0+4 [flutter uuid mime]
- flutter_local_notifications_platform_interface 3.0.0 [flutter plugin_platform_interface]
- flutter_pdfview 1.1.0 [flutter]
- flutter_plugin_android_lifecycle 2.0.1 [flutter]
- flutter_user_agent 1.2.2 [flutter]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform]
- gbk2utf8 1.0.1 [flutter]
- glob 1.2.0 [async collection node_io path pedantic string_scanner]
- graphs 0.2.0
- html 0.14.0+4 [csslib source_span]
- http_multi_server 2.2.0 [async]
- image 2.1.19 [archive xml meta]
- image_picker_for_web 2.0.0 [image_picker_platform_interface meta flutter flutter_web_plugins]
- image_picker_platform_interface 2.0.1 [flutter meta http plugin_platform_interface]
- io 0.3.5 [meta path string_scanner]
- js 0.6.3
- json_annotation 3.1.1
- linkify 4.0.0
- lists 1.0.0 [meta]
- location_platform_interface 1.1.0 [flutter meta plugin_platform_interface]
- location_web 1.0.1 [flutter flutter_web_plugins http_parser js location_platform_interface meta]
- logging 0.11.4
- matcher 0.12.10 [stack_trace]
- meta 1.3.0
- mime 0.9.7
- modal_bottom_sheet 2.0.0 [flutter]
- nested 1.0.0 [flutter]
- node_interop 1.2.1 [js]
- node_io 1.1.1 [node_interop path]
- octo_image 0.3.0 [flutter flutter_blurhash]
- package_config 1.9.3 [path charcode]
- package_info_plus 1.0.0 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web]
- package_info_plus_linux 1.0.0 [package_info_plus_platform_interface flutter path]
- package_info_plus_macos 1.0.0 [flutter]
- package_info_plus_platform_interface 1.0.0 [flutter meta plugin_platform_interface]
- package_info_plus_web 1.0.0 [http package_info_plus_platform_interface flutter flutter_web_plugins meta]
- package_info_plus_windows 1.0.0 [package_info_plus_platform_interface ffi flutter win32]
- path 1.8.0
- path_drawing 0.4.1+1 [vector_math meta path_parsing flutter]
- path_parsing 0.1.4 [vector_math meta]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+8 [flutter]
- path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.5 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.11.0
- permission_handler_platform_interface 3.1.2 [flutter meta plugin_platform_interface]
- petitparser 3.1.0 [meta]
- platform 3.0.0
- pointycastle 2.0.1
- pool 1.5.0 [async stack_trace]
- process 4.0.0 [file path platform]
- pub_semver 1.4.4 [collection]
- pubspec_parse 0.1.8 [checked_yaml json_annotation pub_semver yaml]
- random_string 2.1.0
- rxdart 0.25.0
- sembast 2.4.10+4 [meta path synchronized]
- sentry 5.0.0 [http meta stack_trace uuid]
- shared_preferences_linux 0.0.2+4 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+11 [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]
- shared_preferences_windows 0.0.2+3 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider_windows]
- shelf 1.1.0 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 0.2.4+1 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.99
- source_gen 0.9.10+2 [analyzer async build dart_style glob meta path pedantic source_span]
- source_span 1.8.0 [charcode collection path term_glyph]
- sqflite 2.0.0+3 [flutter sqflite_common path]
- sqflite_common 2.0.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.0 [charcode source_span]
- sync_http 0.2.0
- synchronized 3.0.0
- term_glyph 1.2.0
- test_api 0.2.19 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- timezone 0.7.0 [path]
- timing 0.1.1+3 [json_annotation]
- typed_data 1.3.0 [collection]
- unicode 0.3.0 [lists]
- url_launcher_linux 0.0.1+4 [flutter]
- url_launcher_macos 0.0.1+9 [flutter]
- url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.5+3 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+3 [flutter]
- vector_math 2.1.0
- video_player_platform_interface 4.1.0 [flutter meta flutter_test]
- video_player_web 2.0.0 [flutter flutter_web_plugins meta video_player_platform_interface]
- vin_decoder 0.1.3 [meta basic_utils http random_string]
- vm_service 5.5.0 [meta]
- wakelock_macos 0.1.0 [flutter flutter_web_plugins wakelock_platform_interface]
- wakelock_platform_interface 0.2.0 [flutter meta]
- wakelock_web 0.2.0 [flutter flutter_web_plugins js wakelock_platform_interface]
- watcher 0.9.7+15 [async path pedantic]
- web_socket_channel 1.2.0 [async crypto stream_channel]
- webdriver 2.1.2 [archive matcher path stack_trace sync_http]
- win32 2.0.5 [ffi]
- xdg_directories 0.1.2 [meta path process]
- xml 4.5.1 [collection convert meta petitparser]
- xxtea 2.1.0
- yaml 2.2.1 [charcode collection string_scanner source_span]

@shreyansh2211 shreyansh2211 added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Apr 30, 2021
@markusaksli-nc markusaksli-nc added the triage Issue is currently being triaged. label May 4, 2021
@markusaksli-nc
Copy link
Contributor

Hi @shreyansh2211
What iOS versions are on the older devices?
FYI not being able to handle background messages while the app is terminated is the expected and documented behavior on iOS.
https://firebase.flutter.dev/docs/messaging/usage#receiving-messages

On iOS, if the user swipes away the application from app Switcher, it must be manually reopened again for background messages to start working again.

Thank you

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels May 4, 2021
@shreyansh2211
Copy link
Author

Hi @markusaksli-nc,

Older devices are running iOS 14.4.2.

Background message is handled very well in iphone se 2 , iphone 11 with same iOS version i.e. 14.4.2. Problem is in older devices only.

And onBackgroundmessage is not called even when app is in background on older devices.

And it is also mentioned in document that

Since the handler runs in its own isolate outside your applications context, it is not possible to update application state or execute any UI impacting logic. You can however perform logic such as HTTP requests, IO operations (updating local storage), communicate with other plugins etc.

I am just communicating with other plugin i.e. callKeep and not not performing HTTP request or anything else which is not possible.

If same code is working with newer devices then it should also work with older once otherwise there is some flag or setting or some other way to call onBackgroudMessage to work with older devices which i can't find in firebase documentation.

Please let me know if there is something like that for older iphone devices.

Thankyou.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels May 4, 2021
@markusaksli-nc
Copy link
Contributor

I'm not seeing the issue on an iPhone 7 with iOS 14.5 on firebase_messaging: ^9.1.3

Have you added "content-available": 1 to the message payload?

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels May 4, 2021
@shreyansh2211
Copy link
Author

I have added 'notification': { "content_available": true, } .

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels May 4, 2021
@markusaksli-nc
Copy link
Contributor

If you are sending through the deprecated api then it needs to be added to the payload not the notification key.

For example:

{
  "to": token,
  "notification": {
    "title": "Title",
    "body": "Body",
  },
  "data": {
    "key": "value"
  },
  "content_available": true
}

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels May 4, 2021
@google-oss-bot
Copy link

Hey @shreyansh2211. 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 google-oss-bot added the Stale Issue with no recent activity label May 13, 2021
@google-oss-bot
Copy link

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

@shreyansh2211 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.

@firebase firebase locked and limited conversation to collaborators Jun 24, 2021
@darshankawar darshankawar added resolution: no-response Customer did not respond after some time. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. triage Issue is currently being triaged. labels Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
closed-by-bot resolution: no-response Customer did not respond after some time. Stale Issue with no recent activity type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@google-oss-bot @darshankawar @markusaksli-nc @shreyansh2211 and others