flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

[Question]: how can start when i cancel and restart

Open kindkmj opened this issue 1 year ago • 7 comments

Please check the following before submitting a new issue.

Please select for which platform(s) you need help

  • [X] Android
  • [X] iOS
  • [ ] Linux
  • [ ] macOS
  • [ ] Web
  • [ ] Windows

Your question

i can cancel and how can re-start? resume -> only pause and next action cancel -> ???

Version

11.0.0

kindkmj avatar Jun 05 '24 01:06 kindkmj

Is there any update?

I also want to cancel the foreground service when the user logs out and start it again when the user re-logs in. Additionally, the foreground service notification should also close when the service is canceled.

Is there any predefined method for this?

mayank-vinove avatar Jul 11 '24 04:07 mayank-vinove

init
StreamSubscription<Position>? positionStream;
positionStream =
        Geolocator.getPositionStream(locationSettings: locationSettings).listen(
      (Position? position) async {})....
      
    

cancel

if (positionStream != null) {
      positionStream?.cancel();
      positionStream = null;
    }

re-start

positionStream =
        Geolocator.getPositionStream(locationSettings: locationSettings).listen(
      (Position? position) async {})....
 

i use

kindkmj avatar Jul 11 '24 04:07 kindkmj

@kindkmj when user close/exit the app after start location tracking than again open it how can i find reference of positionStream.

Also does positionStream?.cancel(); automatically dismiss the foreground service notification ?

mayank250004 avatar Jul 11 '24 06:07 mayank250004

If positionStream?.cancel(); no further location collection has taken place. However, there were intermittent cases where collection continued even if canceled occasionally, but it was different for each project. I need to send a location collection notification to the user I also used the location package.

kindkmj avatar Jul 11 '24 08:07 kindkmj

@TimHoogstrate please let me know what info you need.

mayank-vinove avatar Aug 06 '24 14:08 mayank-vinove

Dear @mayank-vinove,

Please elaborate a bit on the subject. Try to explain what you have done so far and what you want to achieve?

Kind regards,

TimHoogstrate avatar Aug 07 '24 07:08 TimHoogstrate

@TimHoogstrate

Check https://github.com/Baseflow/flutter-geolocator/issues/1536

mayank-vinove avatar Aug 08 '24 11:08 mayank-vinove