rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
288 stars 328 forks source link

[iOS] App gets restarted even after locator service is successfully stopped and the app is killed #239

Closed srmncnk closed 2 years ago

srmncnk commented 3 years ago

First of all kudos for developing this plugin! Great work.

I want to use this plugin for navigational purposes and it's been working great. But recently I discovered that when I stop the service and kill the app, I still get the app resurrected when using some other app which fetches location (Google Maps, Apple Maps etc).

How can I avoid this? I do want to be able to track location in background AFTER I started the app, but I don't want to be resurrected once I STOPPED the service.

srmncnk commented 3 years ago

Any progres on this? Any pointer at all?

This is a really troublesome bug on iOS, having a negative UX.

mehdok commented 3 years ago

Hi @srmanc Thank you for opening an issue.

Sadly I missed your issue completely.

But this weekend I have some free time to work on it. Meaning while, please provide any information that might help finding the bug.

srmncnk commented 3 years ago

@mehdok Thanks for replying.

Basically when we start and stop the service on iOS (and even kill the app after service was stopped), the app gets resurrected.

Currently we're testing if setting locationManager.allowsBackgroundLocationUpdates to true on start and to false on stop fixes the bug, but I can't confirm (nor deny) the fix just yet. https://developer.apple.com/documentation/corelocation/cllocationmanager/1620568-allowsbackgroundlocationupdates

srmncnk commented 3 years ago

Update: the last fix did not fix the behaviour, app still restarts randomly.

After intensive reviewing of docs, we've added this call to the stop procedure: https://developer.apple.com/documentation/corelocation/cllocationmanager/1423679-stopmonitoringsignificantlocatio?language=objc

I'll get back with the results.

srmncnk commented 3 years ago

Can confirm the upper (and the mentioned) fix resolves our issues. You can close this freely.