cordova-plugin-geolocation icon indicating copy to clipboard operation
cordova-plugin-geolocation copied to clipboard

Work on background

Open Taxi4you opened this issue 6 years ago • 4 comments

Feature Request

Motivation Behind Feature

Sometimes getting the position when app is on background is crucial.

Feature Description

Get the position on background.

Alternatives or Workarounds

Tried to make the app available on background using a plugin but this is not working and not a good behaviour at all. The GPS should be working on background as well.

Taxi4you avatar Jun 24 '19 14:06 Taxi4you

where you able to make it work on background?

alexisqc92 avatar Sep 05 '20 00:09 alexisqc92

2019 request and still this isn't available? Wow... well I'm sure going to abandon using this one. Just to confirm, this plugin will not retrieve geolocation if you're running your app in background mode.

risharde avatar Apr 14 '21 02:04 risharde

2019 request and still this isn't available? Wow... well I'm sure going to abandon using this one. Just to confirm, this plugin will not retrieve geolocation if you're running your app in background mode.

To be clear, background processing is very limited on hybrid apps as the webview JS engine will be completely paused on iOS, and could be completely paused on some Android devices while the application is in the background.

This means at most, we may be able to collect GPS events that occurred in the background, but can only be passed to your application once the application is brought back into the foreground. Obviously in most cases, you'd want to be able to react to background location events immediately to produce a notification to the user, or to do something with it so receiving a stream of location events that has happened sometime in the past isn't exactly ideal.

Depending on the use case / requirements, the only workaround is to build a cordova plugin that contains your application business logic that responds to background location events.

With that being said, there are existing third-party plugins that do implement background location.

breautek avatar Apr 14 '21 16:04 breautek

Thank you for responding and pointing me in the right direction @breautek ! Really appreciate it

risharde avatar Apr 14 '21 17:04 risharde

Until W3C spec actually declares background usage + the limited execution ability of the WKWebView/js engines on iOS when app is suspended, I don't foresee background support being implemented.

This plugin aims to maintain the W3C standard so that it can cease to exist when the webview itself is capable of handling geolocation.

If background geolocation support is necessary, as mentioned in a previous post there are other third-party plugins that does (or claims to) provide background location updates.

breautek avatar Sep 15 '23 02:09 breautek