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

🐛 [firebase_messaging 8.0.0-dev.8] iOS notification not working #4185

Closed jprcksnts closed 3 years ago

jprcksnts commented 3 years ago

Bug report

I have migrated from v7.0.3 and have successfully fixed the bug in android where the app will crash whenever a push notification is sent when the app is terminated (push notification doesn't show as well if app is terminated).

There was also a bug in iOS on v7.0.3 where the push notification will only show up when the app is foreground. If the push notification is sent while the app is on background or is terminated, it will only shop up once the app is opened (foreground) again.

Hoping to fix the issues above, I migrated to v8, and successfully fixed all notification bugs in android. However, upon testing on iOS, no notification is being received at all.

Steps to reproduce

Steps to reproduce the behavior:

  1. Get the firebase token
  2. Send a notification via FCM to the token
  3. No notification received on iOS whether foreground, background, or terminated.

Expected behavior

Receive notification at any states (foreground/background/terminated).


Additional context

I have the following code on my main

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  Firebase.initializeApp();
}

initialized FirebaseMessaging

FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance;

initialized FirebaseMessaging listener

FirebaseMessaging.onMessage.listen(onMessage);

onMessage(RemoteMessage message) {
print('message received');
}

I also happen to get the following error when manually run via xcode

2020-11-23 07:31:03.422090+0800 Runner[86538:540112] 6.33.0 - [Firebase/Core][I-COR000005] No app has been configured yet.

If I add the ff on AppDelegate.swift

import Firebase 
FirebaseApp.configure()

the error is gone, but the app closes on open.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand [✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B29 darwin-x64, locale en-US) • Flutter version 1.22.4 at /Users/rcksnts/sdk/flutter • Framework revision 1aafb3a8b9 (9 days ago), 2020-11-13 09:59:28 -0800 • Engine revision 2c956a31c0 • Dart version 2.10.4 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/rcksnts/sdk/android • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/rcksnts/sdk/android • 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-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.2, Build version 12B45b • 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-6915495) [!] VS Code (version 1.51.1) • VS Code at /Applications/Visual Studio Code.app/Contents ✗ Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [✓] Connected device (1 available) • iPhone 12 Pro Max (mobile) • 2A029E98-316D-4CB0-8E64-BF952A2956B2 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-2 (simulator)

Flutter dependencies

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

Click To Expand Dart SDK 2.10.4 Flutter SDK 1.22.4 aboitizland_customer_portal 1.1.7+27 dependencies: - auto_size_text 2.1.0 [flutter] - cupertino_icons 1.0.0 - device_info 1.0.0 [flutter device_info_platform_interface] - dio 3.0.10 [http_parser path] - dots_indicator 1.2.0 [flutter] - equatable 1.2.5 [collection meta] - extended_image 1.3.0 [flutter extended_image_library meta] - firebase_core 0.5.2 [firebase_core_platform_interface flutter quiver meta firebase_core_web] - firebase_messaging 8.0.0-dev.8 [meta flutter firebase_core firebase_core_platform_interface firebase_messaging_platform_interface] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_bloc 6.1.1 [flutter bloc provider] - flutter_cached_pdfview 0.3.0 [flutter flutter_pdfview flutter_cache_manager path_provider path] - flutter_local_notifications 3.0.1+5 [flutter platform flutter_local_notifications_platform_interface timezone] - flutter_secure_storage 3.3.5 [meta flutter] - flutter_svg 0.19.1 [flutter meta path_drawing vector_math xml] - http 0.12.2 [http_parser path pedantic] - intl 0.16.1 [path] - json_annotation 3.1.0 - provider 4.3.2+2 [flutter nested collection] - trust_fall 1.0.4 [flutter] - url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows] - validators 2.0.1 [vin_decoder] - vibrate 0.0.4 [flutter] 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 meta source_span stream_channel string_scanner term_glyph typed_data] transitive dependencies: - async 2.5.0-nullsafety.1 [collection] - basic_utils 2.7.0-rc.1 [http logging json_annotation pointycastle convert crypto] - bloc 6.1.0 [meta] - boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner] - characters 1.1.0-nullsafety.3 - charcode 1.2.0-nullsafety.1 - clock 1.1.0-nullsafety.1 - collection 1.15.0-nullsafety.3 - convert 2.1.1 [charcode typed_data] - crypto 2.1.5 [collection convert typed_data] - device_info_platform_interface 1.0.1 [flutter meta plugin_platform_interface] - extended_image_library 0.3.0 [flutter path_provider http_client_helper crypto path] - fake_async 1.2.0-nullsafety.1 [clock collection] - ffi 0.1.3 - file 5.2.1 [intl meta path] - firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver] - firebase_core_web 0.2.1 [firebase_core_platform_interface flutter flutter_web_plugins meta js] - firebase_messaging_platform_interface 1.0.0-dev.5 [flutter meta firebase_core plugin_platform_interface] - flutter_cache_manager 2.0.0 [flutter path_provider uuid http path sqflite pedantic clock file rxdart] - flutter_local_notifications_platform_interface 2.0.0+1 [flutter plugin_platform_interface] - flutter_pdfview 1.0.3+5 [flutter] - flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math] - http_client_helper 0.2.1 [http] - http_parser 3.1.4 [charcode collection source_span string_scanner typed_data] - js 0.6.2 - logging 0.11.4 - matcher 0.12.10-nullsafety.1 [stack_trace] - meta 1.3.0-nullsafety.3 - nested 0.0.4 [flutter] - path 1.8.0-nullsafety.1 - path_drawing 0.4.1+1 [vector_math meta path_parsing flutter] - path_parsing 0.1.4 [vector_math meta] - path_provider 1.6.24 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 0.0.4+6 [flutter] - path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface] - path_provider_windows 0.0.4+3 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.9.2 [meta] - petitparser 3.1.0 [meta] - platform 2.2.1 - plugin_platform_interface 1.0.3 [meta] - pointycastle 2.0.0 - process 3.0.13 [file intl meta path platform] - quiver 2.1.5 [matcher meta] - random_string 2.1.0 - rxdart 0.24.1 - sky_engine 0.0.99 - source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph] - sqflite 1.3.2+1 [flutter sqflite_common path] - sqflite_common 1.0.2+1 [synchronized path meta] - 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] - synchronized 2.2.0+2 - term_glyph 1.2.0-nullsafety.1 - test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.5.9 [path] - typed_data 1.3.0-nullsafety.3 [collection] - 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+1 [url_launcher_platform_interface flutter flutter_web_plugins meta] - url_launcher_windows 0.0.1+3 [flutter] - uuid 2.2.2 [crypto convert] - vector_math 2.1.0-nullsafety.3 - vin_decoder 0.1.2 [meta basic_utils http random_string] - win32 1.7.4 [ffi] - xdg_directories 0.1.2 [meta path process] - xml 4.5.1 [collection convert meta petitparser]

markusaksli-nc commented 3 years ago

Hi @jprcksnts I see there's an open issue addressing the case you described https://github.com/FirebaseExtended/flutterfire/issues/4097. Please follow up on that issue, I'm closing the current one as a duplicate. If you disagree, please write in the comments and I will reopen it. Thank you

cakkiraz commented 3 years ago

Hi, i have tried with new version, firebase_messaging 8.0.0-dev.9, but still does not work for IOS.

ahmetakil commented 3 years ago

I have the same issue with ios for firebase_messaging 8.0.0-dev.9