Location Permissions and Accuracy: Ionic 4

Rajesh Mishra
6 min readJul 19, 2019

Building an App that captures the Device Location??!! Alright.
Let's start with some approaches I tried and failed while developing a Hybrid App using the Ionic Framework.

I am using Ionic 4. The App mainly captures an User’s Location at certain events. Accuracy of the location is really important for the App to work correctly.

I tried multiple, literally all, native plugins available. Some failed, some were ‘OK’ and finally I tried a Mixture of Plugins to achieve what I was intending to do. Let’s see each Approach.

Approach 1: Geolocation Plugin
Ionic Native Geolocation plugin claims to provide the Latitude and Longitude of the Current Device Position. It does.
The getCurrentPosition function sometimes acts weirdly. Like delay in response, incorrect Lat-Lng, etc.
The main issue I faced was that the plugin, most of the time, returns a cached location.
I have researched a lot related to this issue. Many suggested to use maximumAge option with a value as low as possible. Didn’t help. Some suggested to use enableHighAccuracy, but somehow all these suggestions didn’t worked for me.

Still, let's have a look at how to implement and use this Plugin.

--

--

Rajesh Mishra
Rajesh Mishra

Written by Rajesh Mishra

Developer | Blogger I write about tech—simple how-tos to help others (and future me). Also, I explore and share life's experiences that inspire and connect.

Responses (8)