Baseflow / Baseflow/flutter-geolocator

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

Open
#1,353 2 comments 0 reactions 0 assignees View on GitHub
P2 platform: android type: bug
Dominant language
Dart
Stars
1.3k
Forks
803
Avg merge
8h 16m
Merged PRs (30d)
1

Description

### Please check the following before submitting a new issue.

- [X] I have searched the [existing issues](https://github.com/baseflow/flutter-geolocator/issues).
- [X] I have carefully [read the documentation](https://github.com/Baseflow/flutter-geolocator/blob/main/geolocator/README.md) and verified I have added the required platform specific configuration.

### 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](https://github.com/michaelnabil230/geolocator_issue)

### Version

10.1.0

### Flutter Doctor output

Doctor output

```console
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!
```

Contributor guide

Open the contributing guide

Research direction

Clone and run the linked geolocator_issue example, then reproduce the failure using getPositionStream with firebase_messaging after terminating the Android app. Compare the terminated-state output with foreground and background behavior; done means the FlutterJNI and geolocator_updates_android errors no longer appear in the terminal.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, dart, firebase
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.