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.67k stars 3.97k forks source link

πŸ› [firebase_messaging] onResume called when app in backgroun -for iOS only #4003

Closed maciogg closed 3 years ago

maciogg commented 3 years ago

Bug report

onResume is called when app is in backgroun mode - it is for iOS only When app go to foreground mode onResume is calling again

Steps to reproduce

Steps to reproduce the behavior:

  1. Push notification is send
  2. Notification is shown on device
  3. onResume is called (only on iOS - Android is as expected - no onResume)
  4. notification tapped
  5. app going to foreground
  6. onResume is called again

Expected behavior

No onResume called when app is on background mode


Additional context

Add any other context about the problem here.


Flutter doctor

Click To Expand [βœ“] Flutter (Channel master, 1.23.0-8.0.pre.51, on Mac OS X 10.15.7 19H2 x86_64, locale pl-PL) [βœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.2) [βœ“] Xcode - develop for iOS and macOS (Xcode 12.1) [βœ“] Android Studio (version 4.0) [βœ“] VS Code (version 1.50.1) [βœ“] Connected device (1 available) β€’ No issues found! maciej.geciow@MacBook-Pro moja_plytoteka % run flutter doctor -v zsh: command not found: run maciej.geciow@MacBook-Pro moja_plytoteka % flutter doctor -v [βœ“] Flutter (Channel master, 1.23.0-8.0.pre.51, on Mac OS X 10.15.7 19H2 x86_64, locale pl-PL) β€’ Flutter version 1.23.0-8.0.pre.51 at /Users/maciej.geciow/Development/flutter β€’ Framework revision d693d2b9d2 (5 weeks ago), 2020-09-29 09:29:36 -0700 β€’ Engine revision 414805d1d8 β€’ Dart version 2.11.0 (build 2.11.0-176.0.dev) [βœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.2) β€’ Android SDK at /Users/maciej.geciow/Library/Android/sdk β€’ Platform android-30, build-tools 29.0.2 β€’ Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) β€’ All Android licenses accepted. [βœ“] Xcode - develop for iOS and macOS (Xcode 12.1) β€’ Xcode at /Applications/Xcode.app/Contents/Developer β€’ Xcode 12.1, Build version 12A7403 β€’ CocoaPods version 1.9.1 [βœ“] Android Studio (version 4.0) β€’ Android Studio at /Applications/Android Studio.app/Contents β€’ Flutter plugin version 50.0.1 β€’ Dart plugin version 193.7547 β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) [βœ“] VS Code (version 1.50.1) β€’ VS Code at /Applications/Visual Studio Code.app/Contents β€’ Flutter extension version 3.16.0 [βœ“] Connected device (1 available) β€’ AMN LX9 (mobile) β€’ WNPNU20110303518 β€’ android-arm β€’ Android 9 (API 28) β€’ No issues found!

Flutter dependencies

Click To Expand Dart SDK 2.11.0-176.0.dev Flutter SDK 1.23.0-8.0.pre.51 moja_plytoteka 1.1.0+2 |-- about 1.2.0 | |-- flutter... | |-- flutter_markdown 0.4.4 | | |-- flutter... | | |-- markdown... | | |-- meta... | | '-- path... | |-- markdown 2.1.8 | | |-- args... | | |-- charcode... | | '-- meta... | |-- package_info... | |-- path 1.8.0-nullsafety.1 | |-- pedantic 1.9.2 | | '-- meta... | |-- simple_mustache 1.0.0 | | '-- meta... | '-- url_launcher... |-- audioplayers 0.16.2 | |-- flutter... | |-- flutter_web_plugins... | |-- path_provider... | '-- uuid 2.2.2 | |-- convert... | '-- crypto... |-- circular_menu 1.1.0 | '-- flutter... |-- connectivity 0.4.9+5 | |-- connectivity_for_web 0.3.1+2 | | |-- connectivity_platform_interface... | | |-- flutter... | | '-- flutter_web_plugins... | |-- connectivity_macos 0.1.0+5 | | '-- flutter... | |-- connectivity_platform_interface 1.0.6 | | |-- flutter... | | |-- meta... | | '-- plugin_platform_interface... | |-- flutter... | '-- meta... |-- crypto 2.1.5 | |-- collection... | |-- convert 2.1.1 | | |-- charcode... | | '-- typed_data... | '-- typed_data... |-- cupertino_icons 0.1.3 |-- device_info 0.4.2+8 | |-- device_info_platform_interface 1.0.1 | | |-- flutter... | | |-- meta... | | '-- plugin_platform_interface... | '-- flutter... |-- dio 3.0.10 | |-- http_parser... | '-- path... |-- email_validator 1.0.5 |-- equatable 1.2.5 | |-- collection... | '-- meta... |-- filesize 1.0.4 |-- firebase_messaging 7.0.3 | |-- firebase_core 0.5.1 | | |-- firebase_core_platform_interface 2.0.0 | | | |-- flutter... | | | |-- meta... | | | |-- plugin_platform_interface... | | | '-- quiver... | | |-- firebase_core_web 0.2.0 | | | |-- firebase 7.3.2 | | | | |-- http... | | | | |-- http_parser... | | | | '-- js... | | | |-- firebase_core_platform_interface... | | | |-- flutter... | | | |-- flutter_web_plugins... | | | |-- js 0.6.2 | | | '-- meta... | | |-- flutter... | | |-- meta... | | '-- quiver 2.1.4+1 | | |-- matcher... | | '-- meta... | |-- flutter... | '-- meta... |-- flutter 0.0.0 | |-- characters 1.1.0-nullsafety.3 | |-- collection 1.15.0-nullsafety.3 | |-- meta 1.3.0-nullsafety.3 | |-- sky_engine 0.0.99 | |-- typed_data 1.3.0-nullsafety.3 | | '-- collection... | '-- vector_math 2.1.0-nullsafety.3 |-- flutter_launcher_icons 0.8.0 | |-- args 1.6.0 | |-- image 2.1.18 | | |-- archive 2.0.13 | | | |-- args... | | | |-- crypto... | | | '-- path... | | |-- meta... | | '-- xml 4.5.1 | | |-- collection... | | |-- convert... | | |-- meta... | | '-- petitparser 3.1.0 | | '-- meta... | '-- yaml 2.2.1 | |-- charcode... | |-- collection... | |-- source_span... | '-- string_scanner... |-- flutter_test 0.0.0 | |-- async 2.5.0-nullsafety.1 | | '-- collection... | |-- boolean_selector 2.1.0-nullsafety.1 | | |-- source_span... | | '-- string_scanner... | |-- characters... | |-- charcode 1.2.0-nullsafety.1 | |-- clock 1.1.0-nullsafety.1 | |-- collection... | |-- fake_async 1.2.0-nullsafety.1 | | |-- clock... | | '-- collection... | |-- flutter... | |-- matcher 0.12.10-nullsafety.1 | | '-- stack_trace... | |-- meta... | |-- path... | |-- source_span 1.8.0-nullsafety.2 | | |-- charcode... | | |-- collection... | | |-- path... | | '-- term_glyph... | |-- stack_trace 1.10.0-nullsafety.1 | | '-- path... | |-- stream_channel 2.1.0-nullsafety.1 | | '-- async... | |-- string_scanner 1.1.0-nullsafety.1 | | |-- charcode... | | '-- source_span... | |-- term_glyph 1.2.0-nullsafety.1 | |-- test_api 0.2.19-nullsafety.2 | | |-- async... | | |-- boolean_selector... | | |-- collection... | | |-- matcher... | | |-- meta... | | |-- path... | | |-- source_span... | | |-- stack_trace... | | |-- stream_channel... | | |-- string_scanner... | | '-- term_glyph... | |-- typed_data... | '-- vector_math... |-- font_awesome_flutter 8.10.0 | '-- flutter... |-- hexcolor 1.0.6 | |-- flutter... | '-- flutter_web_plugins 0.0.0 | |-- characters... | |-- collection... | |-- flutter... | |-- meta... | |-- typed_data... | '-- vector_math... |-- http 0.12.2 | |-- http_parser 3.1.4 | | |-- charcode... | | |-- collection... | | |-- source_span... | | |-- string_scanner... | | '-- typed_data... | |-- path... | '-- pedantic... |-- intl 0.16.1 | '-- path... |-- ios_utsname_ext 1.0.0 | '-- flutter... |-- network_to_file_image 2.3.6 | '-- flutter... |-- package_info 0.4.3 | '-- flutter... |-- page_transition 1.1.6 | '-- flutter... |-- path_provider 1.6.22 | |-- flutter... | |-- path_provider_linux 0.0.1+2 | | |-- flutter... | | |-- path... | | |-- path_provider_platform_interface... | | '-- xdg_directories 0.1.2 | | |-- meta... | | |-- path... | | '-- process 3.0.13 | | |-- file... | | |-- intl... | | |-- meta... | | |-- path... | | '-- platform... | |-- path_provider_macos 0.0.4+4 | | '-- flutter... | |-- path_provider_platform_interface 1.0.3 | | |-- flutter... | | |-- meta... | | |-- platform 2.2.1 | | '-- plugin_platform_interface 1.0.2 | | '-- meta... | '-- path_provider_windows 0.0.4+1 | |-- ffi... | |-- flutter... | |-- meta... | |-- path... | |-- path_provider_platform_interface... | '-- win32 1.7.3 | '-- ffi... |-- percent_indicator 2.1.7+4 | '-- flutter... |-- rflutter_alert 1.1.0 | '-- flutter... |-- shared_preferences 0.5.12 | |-- flutter... | |-- meta... | |-- shared_preferences_linux 0.0.2+2 | | |-- file 5.2.1 | | | |-- intl... | | | |-- meta... | | | '-- path... | | |-- flutter... | | |-- meta... | | |-- path... | | |-- path_provider_linux... | | '-- shared_preferences_platform_interface... | |-- shared_preferences_macos 0.0.1+10 | | |-- flutter... | | '-- shared_preferences_platform_interface... | |-- shared_preferences_platform_interface 1.0.4 | | |-- flutter... | | '-- meta... | |-- shared_preferences_web 0.1.2+7 | | |-- flutter... | | |-- flutter_web_plugins... | | |-- meta... | | '-- shared_preferences_platform_interface... | '-- shared_preferences_windows 0.0.1+1 | |-- ffi 0.1.3 | |-- file... | |-- flutter... | |-- meta... | |-- path... | |-- path_provider_platform_interface... | |-- path_provider_windows... | '-- shared_preferences_platform_interface... |-- url_launcher 5.7.2 | |-- flutter... | |-- url_launcher_linux 0.0.1+1 | | '-- flutter... | |-- url_launcher_macos 0.0.1+8 | | '-- flutter... | |-- url_launcher_platform_interface 1.0.8 | | |-- flutter... | | |-- meta... | | '-- plugin_platform_interface... | |-- url_launcher_web 0.1.4+1 | | |-- flutter... | | |-- flutter_web_plugins... | | |-- meta... | | '-- url_launcher_platform_interface... | '-- url_launcher_windows 0.0.1+1 | '-- flutter... '-- webview_flutter 1.0.3 '-- flutter...

TahaTesser commented 3 years ago

Hi @maciogg Just tried on ios on the latest stable plugins as seen your plugins logs

[+20991 ms] flutter: onResume: {id: 1, google.c.a.c_id: 9212739073003242153, gcm.n.e: 1, google.c.a.e: 1, gcm.message_id:
1604409599880144, google.c.sender.id: 486685679562, gcm.notification.sound2: default, google.c.a.udt: 0, google.c.a.ts:
1604409599, aps: {mutable-content: 1, alert: {title: Test, body: This is a test}, badge: 1, sound: default}, click_action:
FLUTTER_NOTIFICATION_CLICK, status: done}

onResume is only called when you tap on the notification and never got called when in background on the latest stable flutter channel

flutter doctor -v ```bash [βœ“] Flutter (Channel stable, 1.22.3, on Mac OS X 10.15.7 19H2, locale en-GB) β€’ Flutter version 1.22.3 at /Users/tahatesser/Code/flutter_stable β€’ Framework revision 8874f21e79 (5 days ago), 2020-10-29 14:14:35 -0700 β€’ Engine revision a1440ca392 β€’ Dart version 2.10.3 [βœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.2) β€’ Android SDK at /Users/tahatesser/Code/sdk β€’ Platform android-30, build-tools 30.0.2 β€’ ANDROID_HOME = /Users/tahatesser/Code/sdk β€’ Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) β€’ All Android licenses accepted. [βœ“] Xcode - develop for iOS and macOS (Xcode 12.1) β€’ Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer β€’ Xcode 12.1, Build version 12A7403 β€’ CocoaPods version 1.10.0 [!] Android Studio (version 4.1) β€’ Android Studio at /Applications/Android Studio.app/Contents βœ— Flutter plugin not installed; this adds Flutter specific functionality. βœ— Dart plugin not installed; this adds Dart specific functionality. β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) [βœ“] VS Code (version 1.50.1) β€’ VS Code at /Applications/Visual Studio Code.app/Contents β€’ Flutter extension version 3.16.0 [βœ“] Connected device (1 available) β€’ Taha’s iPhone (mobile) β€’ 00008020-001059882212002E β€’ ios β€’ iOS 14.1 ! Error: Taha’s iPhone is busy: Copying cache files from device. Xcode will continue when Taha’s iPhone is finished. (code -10) ! Doctor found issues in 1 category. ```

Can you please reproduce this issue consistently?