Open Wian-TMC opened 3 years ago
I had code as follows:
final isRunning = await BackgroundLocationHelper.isRunning();
if (!isRunning) {
BackgroundLocationHelper.startTracking(distanceToFilter: 5000.0);
} else {
await BackgroundLocationHelper.unsubLocationService();
BackgroundLocationHelper.startTracking(distanceToFilter: 5000.0);
}
It seems the isRunning() function will return true when changing app permissions on the fly even if the locator exited due to permission changes, so a force to unsub is necessary to get the foreground notification back and the callback to be called again.
So a fix is just always running
await BackgroundLocationHelper.unsubLocationService();
BackgroundLocationHelper.startTracking(distanceToFilter: 5000.0);
irrespective if the Locator is already running or not
I do not know if this is the intended functionality, so I am re-opening it
Issue still stands after 1.6.3.
registerLocationUpdate()
will not run unless you run unRegisterLocationUpdate()
. This is because the locator still thinks it is running in the background -> Confirmed with isServiceRunning()
, which always returns true after the above procedure.
Only tested on Android