Coder Social home page Coder Social logo

Comments (8)

bitboxfw avatar bitboxfw commented on May 28, 2024

I'm having exact the same problem with the same versions on iOS. Same code on Android is working fine.

Did anyone find a solution for the problem?

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 28, 2024

I've created a gist that covers the top reasons why you may not receive GPS results in a timely fashion which can be read here

Note that iOS on a cold-start will fire a few GPS points immediately regardless of how accurate or inaccurate the GPS points are, which explains "called 2-3 times."

from cordova-plugin-geolocation.

vlntn-t avatar vlntn-t commented on May 28, 2024

I have the same issue. Did anyone already find a solution or workaround for this?

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 28, 2024

Couple of notes on why you may not be seeing gps updates

  1. You're in a poor environment, such as in a large office building or basement.
  2. Ios implements a distance filter, which I believe Cordova hardcodes to 5 meters when in high accuracy mode (10 meters otherwise if memory serves me right). Therefore you have to be actually moving to receive gps updates, at least 5-10 meters approximately before ios will propagate gps events.

from cordova-plugin-geolocation.

vlntn-t avatar vlntn-t commented on May 28, 2024

Thanks for your fast response. I checked both of your points. But unfortunately it still wont work. I tested it on both iPhone and iPad with iOS 13.3.

It seems like iOS stops updating the geolocation after 2-5 seconds. Also the status bar GPS symbol disappears after a few seconds.

On the xCode simulator everything works perfectly fine.

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 28, 2024

The described behaviour really sounds like an environmental issue.

But here is a couple more tips...

I don't access to an iOS device at this moment, and I'm not very familiar with the iOS location settings, but ensure that high accuracy is enabled, or that wifi/cell towers for location tracking is enabled. Anything that is "GPS Only" will take a very long time for devices to obtain a satellite fix (Generally this takes 10-15 minutes from a cold start). This is unfortunately a phone setting, not an app setting, so if this solves the problem, then there is very little you can do other than give appropriate error feedback to the user.

Another thing you can try is to remove the distance filter. I would recommend doing this only to ensure that you're not getting gps points filtered while debugging. It isn't recommended to keep it like this for most applications because it will cause battery drain, but might aid in debugging.

self.locationManager.distanceFilter = 5;

You can temporarily modify this line to ensure that GPS isn't being filtered by distance travelled. Set distanceFilter to kCLDistanceFilterNone to disable the filter, so events will be triggered even if the user hasn't moved a significant distance.

Lastly, if the issue persists, I would recommend creating a basic barebones sample app with the minimum requirements to reproduce the issue. So for example, a pure cordova with only the cordova-plugin-geolocation installed, but not ionic, or any other framework. This is to help isolate the issue away from frameworks and prove that the issue lies inside Cordova, and will also provide us an usable test case that can be used when applying patches.

from cordova-plugin-geolocation.

jpangburn avatar jpangburn commented on May 28, 2024

I can confirm @breautek 's comment. The problem you are likely experiencing is the distanceFilter. If you move less than 5 meters, you won't get an update. While this is probably great for driving apps, for apps on foot where you're trying to store a reasonably precise point it won't really work for you. I imagine the people reporting this are not moving far when reporting "it stops after 2-5 seconds", this is the time when the GPS is locating you and precision is increasing. Once it has good precision, you won't get more updates until you move more than 5 meters.

Fixing the line as he says resolves the problem. You can put 0 or kCLDistanceFilterNone. You'll get updates, in my testing, if the device moves even half a foot.

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 28, 2024

Closing as stale

from cordova-plugin-geolocation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.