You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@pragma('vm:entry-point')
Future<void> geofenceTriggered(GeofenceCallbackParams params) async {
const MethodChannel channel = MethodChannel('com.myappp.name/methods');
try {
debugPrint('Geofence triggered with params: $params');
// i have tried with this it returned error
if (params.event == GeofenceEvent.enter) {
await channel.invokeMethod('start');
} else {
await channel.invokeMethod('stop');
}
// 2. i have tried this it works
// but it works when app is active
final sendPort = IsolateNameServer.lookupPortByName(AppConstants.kGeofenceIsolateName);
if (sendPort != null) {
sendPort.send([params.event.name, params.geofences.first.id]);
}
} catch (e, s) {
LogService.e('Error on geofenceTriggered $s $e');
}
}
returned error:
I/flutter ( 6959): │ ⛔ MissingPluginException(No implementation found for method startTracking on channel com.myappp.name/methods)
Problem:
when geofence triggering (enter,exit) i should call channel methods. but it doesnt work. what can i do?
The text was updated successfully, but these errors were encountered:
It sounds like you are trying to use Flutter plugins in an isolate.
This is unfortunately a Flutter limitation, the plugins are not registered in spawned isolates; and the geofence trigger is running in an insolate.
For a 1P workaround see this. Unfortunately, I don't think there is a way to obtain the RootIsolateToken when the app isn't active.
Another option might be to look into https://pub.dev/packages/flutter_isolate. This might require some code changes in this repo and I'm happy to review PRs if you're willing to contribute.
In any case, this is an interesting use case. IIUC you are trying to start geolocator to fetch GPS location in response to a geofence trigger. I'd be interested to know how you get this to work. Please keep us updated.
PS: The promoteToForeground method should come in handy since IIRC Android doesn't allow fetching user location without a foreground service.
i've already wroted my location tracking plagin in native side. it works when user tap start or stop button (at this time app is active so it works i think). And next i need automatic tracking, it means when user entered to region should start my service, when exit should stop my service.
If you have any suggestion at this situatuion, for example " in native side, you can listen this plugin events " please explain to me
Thanks for reply
narzullayev0772
changed the title
I/flutter ( 6959): │ ⛔ MissingPluginException(No implementation found for method startTracking on channel com.myappp.name/methods)
I/flutter ( 6959): │ ⛔ MissingPluginException(No implementation found for method start on channel com.myappp.name/methods)
Dec 27, 2024
returned error:
I/flutter ( 6959): │ ⛔ MissingPluginException(No implementation found for method startTracking on channel com.myappp.name/methods)
Problem:
when geofence triggering (enter,exit) i should call channel methods. but it doesnt work. what can i do?
The text was updated successfully, but these errors were encountered: