i need my app to send the current location over to an API in the background ,specifically when the app is closed. I found that there are restrictions as to how it can be implemented for IOS. Is there any solution in flutter to implement this for both platforms?
Position userLocation = await geoLocator. getCurrentPosition(desiredAccuracy: LocationAccuracy. high); As you have guessed, this line will actually get the current position.
Get user's latitude and longitude To query the current location of the device, simply make a call to the getCurrentPosition() method. For example: import 'package:geolocator/geolocator. dart';Position position = await Geolocator.
So far i have found a plugin that works in the background - except is it not free.
flutter_background_geolocation 1.7.3
https://pub.dev/packages/flutter_background_geolocation
It does exactly what you would want - work in the background for both platforms, you can use it in development for free, but when you launch the app - you need to pay for it (Android platform).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With