Skip to content
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

I/flutter ( 6959): │ ⛔ MissingPluginException(No implementation found for method start on channel com.myappp.name/methods) #7

Open
narzullayev0772 opened this issue Dec 26, 2024 · 2 comments

Comments

@narzullayev0772
Copy link

@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?

@orkun1675
Copy link
Contributor

orkun1675 commented Dec 27, 2024

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.

@narzullayev0772
Copy link
Author

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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants