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.62k stars 3.95k forks source link

πŸ› [Firebase Message + Crash Analytics] Not working in iOS and Android platforms. #6607

Closed ccs1428 closed 3 years ago

ccs1428 commented 3 years ago

Bug report

Describe the bug In android while running the project in Android getting this error.

Firebase.initializeApp() process is success.

When we try to run in gettoken methos getting this error.

_messaging = FirebaseMessaging.instance;
      _messaging.getToken().then((token) async{
        print("....get token.....$token....");
      });
E/flutter (10762): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: [firebase_messaging/unknown] java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: SERVICE_NOT_AVAILABLE

E/flutter (10762): #0      MethodChannelFirebaseMessaging.getToken (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:228:7)

Sharing android log details

2021-07-14 13:12:16.230 10762-11122/com.mediaindia.qleedo E/FirebaseMessaging: Topic sync or token retrieval failed on hard failure exceptions: java.util.concurrent.ExecutionException: java.io.IOException: SERVICE_NOT_AVAILABLE. Won't retry the operation.
2021-07-14 13:12:16.262 10762-11336/com.mediaindia.qleedo I/flutter: application initialised
2021-07-14 13:12:16.373 10762-11336/com.mediaindia.qleedo E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: [firebase_messaging/unknown] java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: SERVICE_NOT_AVAILABLE
    #0      MethodChannelFirebaseMessaging.getToken (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:228:7)
    <asynchronous suspension>
2021-07-14 13:12:18.725 10762-11336/com.mediaindia.qleedo I/flutter: CALLBACK: _onCalendarCreated
2021-07-14 13:12:20.664 10762-11336/com.mediaindia.qleedo E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: [firebase_messaging/unknown] java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: SERVICE_NOT_AVAILABLE
    #0      MethodChannelFirebaseMessaging.getToken (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:228:7)
    <asynchronous suspension>
2021-07-14 13:12:20.706 10762-11336/com.mediaindia.qleedo I/flutter: ..true..MyApp.....false...
2021-07-14 13:12:20.723 10762-11336/com.mediaindia.qleedo E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
    #0      MethodChannelFirebaseMessaging.registerBackgroundMessageHandler (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:179:53)
    #1      FirebaseMessagingPlatform.onBackgroundMessage= (package:firebase_messaging_platform_interface/src/platform_interface/platform_interface_messaging.dart:101:16)
    #2      FirebaseMessaging.onBackgroundMessage (package:firebase_messaging/src/messaging.dart:83:31)
    #3      PushNotificationService.initialise (package:qleedo/helper/PushNotificationService.dart:73:23)
    #4      _DashboardState.registerPushNotification (package:qleedo/screens/dashboard.dart:59:29)
    <asynchronous suspension>
2021-07-14 13:12:20.922 10762-10762/com.mediaindia.qleedo W/Looper: Slow Looper main: Long Msg: seq=58 plan=13:12:19.873  late=2ms wall=1020ms running=13ms runnable=5ms io=10ms h=android.app.ActivityThread$H w=137
2021-07-14 13:12:20.997 10762-10762/com.mediaindia.qleedo W/Looper: Slow Looper main: Activity com.mediaindia.qleedo/.MainActivity is 727ms late (wall=12ms running=2ms ClientTransaction{ callbacks=[android.app.servertransaction.WindowVisibilityItem] }) because of 5 msg, msg 1 took 1020ms (seq=58 running=13ms runnable=5ms io=10ms late=2ms h=android.app.ActivityThread$H w=137)
2021-07-14 13:12:21.116 10762-11336/com.mediaindia.qleedo I/flutter: ..null....new message........null...
2021-07-14 13:12:21.132 10762-11336/com.mediaindia.qleedo E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: [firebase_messaging/unknown] java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: SERVICE_NOT_AVAILABLE
    #0      MethodChannelFirebaseMessaging.getToken (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:228:7)
    <asynchronous suspension>
2021-07-14 13:12:33.277 10762-11337/com.mediaindia.qleedo E/libEGL: call to OpenGL ES API with no current context (logged once per thread)

Steps to reproduce

Steps to reproduce the behavior: Yaml configuration

  firebase_crashlytics: ^2.0.7
  #Social Login
  flutter_signin_button: ^2.0.0
  firebase_auth: ^2.0.0
  firebase_core: ^1.1.0
  #flutter_facebook_auth: ^3.5.0
  google_sign_in: ^5.0.4
  google_sign_in_web: ^0.10.0
  # Push Notifications
  firebase_messaging: ^10.0.0

Additional context

Ios platform token generation is success, but push notification not recieving.


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 unknown, 2.2.1, on macOS 11.4 20F71 darwin-x64, locale en-GB) [βœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [βœ“] Xcode - develop for iOS and macOS [βœ“] Chrome - develop for the web [βœ“] Android Studio (version 4.1) [βœ“] VS Code (version 1.58.0) [βœ“] Connected device (2 available) ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.13.1 Flutter SDK 2.2.1 qleedo 1.0.0+1 dependencies: - connectivity 3.0.6 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web] - cupertino_icons 0.1.3 - firebase_auth 2.0.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.3.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.0.7 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 10.0.3 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_picker 2.0.2 [flutter] - flutter_signin_button 2.0.0 [flutter font_awesome_flutter] - flutter_spinkit 5.0.0 [flutter] - flutter_tts 3.1.0 [flutter flutter_web_plugins] - fluttertoast 8.0.7 [flutter flutter_web_plugins] - google_maps_flutter 2.0.6 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface] - google_maps_flutter_web 0.3.0+2 [flutter flutter_web_plugins google_maps_flutter_platform_interface google_maps meta sanitize_html stream_transform] - google_sign_in 5.0.4 [google_sign_in_platform_interface google_sign_in_web flutter meta] - google_sign_in_web 0.10.0 [google_sign_in_platform_interface flutter flutter_web_plugins meta js] - http 0.13.3 [async http_parser meta path pedantic] - indexed_list_view 2.0.0 [flutter] - intl 0.17.0 [clock path] - loading_overlay 0.3.0 [flutter] - provider 5.0.0 [collection flutter nested] - scroll_to_index 2.0.0 [flutter] - shared_preferences 2.0.6 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows] - speech_to_text 4.2.1 [flutter speech_to_text_platform_interface json_annotation clock pedantic flutter_web_plugins meta js] - table_calendar 2.3.3 [flutter intl simple_gesture_detector] - universal_html 2.0.8 [async csslib charcode collection html meta source_span typed_data universal_io] - url_launcher 6.0.7 [flutter meta url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - webview_flutter 2.0.9 [flutter] - youtube_player_flutter 8.0.0 [flutter flutter_inappwebview] 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.6.1 [meta collection] - boolean_selector 2.1.0 [source_span string_scanner] - characters 1.1.0 - charcode 1.2.0 - clock 1.1.0 - collection 1.15.0 - connectivity_for_web 0.4.0 [connectivity_platform_interface flutter_web_plugins flutter] - connectivity_macos 0.2.0 [flutter] - connectivity_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - crypto 3.0.1 [collection typed_data] - csslib 0.17.0 [source_span] - fake_async 1.2.0 [clock collection] - ffi 1.1.2 - file 6.1.2 [meta path] - firebase_auth_platform_interface 5.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 2.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.0.6 [collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 3.0.2 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.0.2 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - flutter_inappwebview 5.3.2 [flutter] - flutter_plugin_android_lifecycle 2.0.2 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - font_awesome_flutter 9.1.0 [flutter] - google_maps 5.1.0 [js_wrapping meta] - google_maps_flutter_platform_interface 2.1.0 [collection flutter meta plugin_platform_interface stream_transform] - google_sign_in_platform_interface 2.0.1 [flutter meta quiver] - html 0.15.0 [csslib source_span] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - js 0.6.3 - js_wrapping 0.7.0 [js] - json_annotation 4.0.1 - matcher 0.12.10 [stack_trace] - meta 1.3.0 - nested 1.0.0 [flutter] - path 1.8.0 - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.11.1 - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - process 4.2.1 [file path platform] - quiver 3.0.1 [matcher] - sanitize_html 2.0.0 [html meta] - shared_preferences_linux 2.0.0 [flutter file meta path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 2.0.0 [shared_preferences_platform_interface flutter] - shared_preferences_platform_interface 2.0.0 [flutter] - shared_preferences_web 2.0.0 [shared_preferences_platform_interface flutter flutter_web_plugins meta] - shared_preferences_windows 2.0.0 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider_windows] - simple_gesture_detector 0.2.0 [flutter] - sky_engine 0.0.99 - source_span 1.8.1 [collection path term_glyph] - speech_to_text_platform_interface 2.0.0 [flutter meta plugin_platform_interface] - 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] - term_glyph 1.2.0 - test_api 0.3.0 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - typed_data 1.3.0 [collection] - universal_io 2.0.4 [collection crypto meta typed_data] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.3 [flutter plugin_platform_interface] - url_launcher_web 2.0.1 [flutter flutter_web_plugins meta url_launcher_platform_interface] - url_launcher_windows 2.0.0 [flutter] - vector_math 2.1.0 - win32 2.0.5 [ffi] - xdg_directories 0.2.0 [meta path process] ```

markusaksli-nc commented 3 years ago

Hi @ccs1428 Is the device connected to the internet? What device does this happen on? Thank you

ccs1428 commented 3 years ago

Hi @ccs1428 Is the device connected to the internet? What device does this happen on? Thank you

Yes, internet is connected. Device name Redmi 8A Dual

markusaksli-nc commented 3 years ago

Have you tried this on any other devices?

ccs1428 commented 3 years ago

I have tried on both Android and iOS devices.

in ios token generation is working fine, but push notification not receiving.

in android failed in getToken call method .

markusaksli-nc commented 3 years ago

Have you tried running the example?

ccs1428 commented 3 years ago

Will try this example and update , thank you.

ccs1428 commented 3 years ago

@markusaksli-nc Have tried sample application in Android and iOS version. Android notification is now working fine. But still iOS notification not working in background and foreground mode.

ccs1428 commented 3 years ago

@markusaksli-nc Thats my configuration issue in firebase, now iOS push also working fine. Thank you so much for your kind support.

markusaksli-nc commented 3 years ago

Glad you could solve it. Closing the issue as solved.

carman247 commented 3 years ago

@markusaksli-nc Have tried sample application in Android and iOS version. Android notification is now working fine. But still iOS notification not working in background and foreground mode.

Hi, what did you do differently in you app to prevent this error from occurring?

ccs1428 commented 3 years ago

@carman247 Mine was firebase configuration issue, forgot to configure apns key .