Continuous Learning Applications

dev-bloguser

admin

September 27, 2022

Smart Start | Development

NOTES FROM LOCATION DETERMINATION ON THE APP

A 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.

3. ensure that high accuracy is enabled, or that wifi/cell towers for location tracking are 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.

4. 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.

Cordova-plugin-geolocation/src/ios/CDVLocation.m

Line 144 in 6570cf9

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

5. 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 a usable test case that can be used when applying patches.

6. Use another third-party plugin called the Diagnostic plugin in conjunction with the geolocation plugin. It provides several APIs to figure out the current state of required features. Such as if the user has granted permissions, or if the GPS feature is turned off completely, etc. I use this to provide helpful feedback to the user if they need to change something.

Share

smartlybuilt-facebook-blog smartlybuilt-linkedin-blog smartlybuilt-twitter-blog

Similar Posts