HaylLtd / cordova-background-geolocation-plugin

Background and foreground geolocation plugin for Cordova.
Apache License 2.0
57 stars 66 forks source link

Can't switch from background to foreground mode while running #139

Closed veitbjarsch closed 1 year ago

veitbjarsch commented 1 year ago

Describe the bug Changing the startForeground config setting from false to true, while the service is running, doesn't apply the change.

To Reproduce Steps to reproduce the behavior:

  1. BackgroundGeolocation.configure({ startForeground: true, notificationTitle: 'Some title', notificationText: 'Some text', notificationIconColor: '#30679a', notificationIconSmall: 'some_icon' })
  2. BackgroundGeolocation.start();
  3. BackgroundGeolocation.configure({ startForeground: false });
  4. Foreground notification does not appear

Expected behavior Should display the foreground notification in the

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Additional context The other way around it works without a problem (starting in foreground and switching to background mode.

HarelM commented 1 year ago

Sounds right, this isn't a dynamic property and should be applied when the service starts... Why would you need to change it?

veitbjarsch commented 1 year ago

But the service restarts once I update the config. I also tried to stop and restart the geolocation, but it produces the same problem.

I need to change it because I only need the Foreground tracking if a specific progress is running other than that the tracking is only important when the app is in focus. So a Foreground message is not necessary.

Update: Okay now I realize that all of these functions are promise based if I don't add any handler to them. Good to know. This solved all of my problems and I can even cleanup my code.