-
Notifications
You must be signed in to change notification settings - Fork 124
FlutterJNI was detached from native C++ #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This error occurs when you subscribe to a stream and do not unsubscribe from the stream when exiting the app. Be sure to call the NOTE: Code to get a stream like void startCallback() {
final positionStream = Geolocator.getPositionStream();
StreamSubscription<Position>? streamSubscription;
FlutterForegroundTask.initDispatcher((timestamp, sendPort) async {
if (streamSubscription != null) return;
streamSubscription = positionStream.listen((event) {
print('timestamp: ${timestamp.toString()}');
FlutterForegroundTask.update(
notificationTitle: 'Current Position',
notificationText: '${event.latitude}, ${event.longitude}');
});
}, onDestroy: (timestamp) async {
await streamSubscription?.cancel(); // here
print('Dispatcher is dead.. x_x');
});
} The implementation process is as follows:
|
Yess I followed the instructions and now it's working awesome. |
As it looks
What is the alternative version of the code above for |
Error:
W/FlutterJNI(31092): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: step_count. Response ID: 0
When I closed the app, sometimes while walking the debug console shows me this message. Can you help me with this, why I'm getting this error?
The text was updated successfully, but these errors were encountered: