question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IOS foreground mode not update location as realtime as in android

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
pbrauncommented, Sep 20, 2016

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 and stop 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.

1reaction
mauron85commented, Sep 14, 2016

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Location.startLocationUpdatesAsync - no realtime updates on ...
Summary of Issue. Using Location. startLocationUpdatesAsync with foregroundService gets much less updates than when the app is opened and in foreground.
Read more >
Handling location updates in the background - Apple Developer
Configure your app to receive location updates when it isn't running in the foreground.
Read more >
How do I get a background location update every n minutes in ...
Go to Project -> Capabilities -> Background Modes -> select Location updates. Go to Project -> Info -> add a key NSLocationAlwaysUsageDescription with...
Read more >
Location updates in Android 11
If you request a foreground location permission and the background location permission at the same time, the system ignores the request and doesn't...
Read more >
Track Users Location in the Background with Android and ...
Learn how to track a users or device location in the background on Android. Using Xamarin.Forms and Essentials, we will see how to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found