flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

[Bug]: Issues with Firebase Messaging when app is terminated

Open michaelnabil230 opened this issue 1 year ago • 2 comments

Please check the following before submitting a new issue.

Please select affected platform(s)

  • [X] Android
  • [ ] iOS
  • [ ] Linux
  • [ ] macOS
  • [ ] Web
  • [ ] Windows

I am encountering issues when using the firebase_messaging and geolocator plugins in a Flutter app. Specifically, the problem arises when I try to use the getPositionStream method from the geolocator plugin while the app is terminated.

The error messages I am encountering in the terminal are as follows:

  1. "Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: flutter.baseflow.com/geolocator_updates_android. Response ID: 16"

These errors seem to be related to the interaction between the geolocator plugin and the firebase_messaging plugin when the app is in a terminated state. This issue does not occur when the app is in the foreground or background.

Steps to reproduce

  1. Clone the example code from the provided GitHub repository.
  2. Run the app.
  3. Terminate the app (e.g., swipe it away from the recent apps list).
  4. Observe the error messages in the terminal.

Expected results

The geolocator plugin should work as expected, even when the app is terminated. It should not produce the mentioned error messages.

Actual results

The error messages mentioned above are displayed in the terminal when using the geolocator plugin in combination with the firebase_messaging plugin while the app is terminated.

Code sample

Can clone the app to test the issue Link in Github

Version

10.1.0

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.6, on macOS 14.0 23A344 darwin-arm64, locale
    en-EG)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.83.0)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

michaelnabil230 avatar Oct 09 '23 20:10 michaelnabil230

Thank you for reaching out @michaelnabil230. Appreciate the example app! Just a heads-up that it contains API keys that you might want to keep hidden.

Seems like we are holding onto old method channel instances. A quick search yields the following StackOverflow page: https://stackoverflow.com/questions/61934900/tried-to-send-a-platform-message-to-flutter-but-flutterjni-was-detached-from-n.

This will require further investigation. I will add it to our list.

We want to stimulate the community to contribute to the plugins. If you are able to dig into the issue yourself, you are free to open a PR yourself. We will gladly assist you.

JeroenWeener avatar Oct 10 '23 11:10 JeroenWeener

Hi @JeroenWeener @mvanbeusekom

Any news on fixing this issue?

michaelnabil230 avatar Jan 23 '24 11:01 michaelnabil230