cordova-plugin-background-geolocation: IOS foreground mode not update location as realtime as in android
In IOS, I have to wait longer than expect to get location from callback function. As in android device, I got the location similar to HTML5.geolocation.watchPosition.
Your Environment
- Plugin version: 2.1.2
- Platform: iOS
- Device manufacturer and model:
- Cordova version (
cordova -v
): 6.1.1 - Cordova platform version (
cordova platform ls
): ios 4.1.1 - Plugin configuration options:
[
desiredAccuracy: 0,
stationaryRadius: 5,
distanceFilter: 1,
activityType: 'AutomotiveNavigation',
// debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
// stopOnTerminate: false, // <-- enable this
locationProvider: backgroundGeolocation.provider.ANDROID_ACTIVITY_PROVIDER,
interval: 3000, // <!-- poll for position every minute
fastestInterval: 500,
]
Expected Behavior
In foreground mode, I think we should able to get location as soon as possible like android did. In ios, the location will be callback around 20 sec.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (8 by maintainers)
Commits related to this issue
- changes to allow highest accuracy https://github.com/mauron85/cordova-plugin-background-geolocation/issues/124 — committed to luigi37/cordova-plugin-background-geolocation by luigi37 7 years ago
FYI, Since I couldn’t quickly figure out how to natively improve the accuracy I found a work around that kind of works for my app. As per your suggestion I used the HTML 5 geolocation feature, which works well for real-time updates, but it doesn’t run in the background by itself. I found out that with the “cordova-plugin-background-geolocation” installed and configured, for some reason, it allows me to run the HTML5 geolocation code in the background. I only had to configure the plugin then call
start
andstop
onsuccess, just once. The only disadvantage now is that every time I use the app the HTML5 geolocation feature asks for GPS permission. For some reason the WebView doesn’t remember the user’s decision. For my use-case that’s not a big issue though.yeah it should work better with option disableElasticity which basically turns off distanceFilter. Anyway as there is more and more people asking for this kind of behaviour, I’m thinking about creating bare version to suit your needs.