I have a problem with Geolocation, i think use ionic was a mistake :(

Hello there, i’m new using IONIC, but i believe to know a couple of things about it, however i can’t get Geolocation to work properly in Android device. Really i can´t understand Ionic Documentation or maybe i dont how to search, im moving from Phonegap where to get Geolocation working properly it’s very very simple, so i think may be i’m making something very very vey bad, if you want to save my life (literaly) please take a look on to this code:

This is my /src/app/app.components.ts file

See Image

I ran this command

ionic plugin add cordova-plugin-geolocation

This is my /plattforms/android/AndroidManifest.xml file

I have even tested calling Geolocation functions from my home.ts file


But same results.

Same results without enableHighAccuracy param

I really don’t what else can i do, or where can i take a look, thank you for your time

EDITED 2017-02-07

This looks like the relevant part of my home.ts file I am calling the api Geolocation from this file instead of calling it in the file app.components.ts


I’ve tried enableHighAccuracy true and false even I’ve tried without the enableHighAccuracy parameter. Same result, no response from the call to Geolocation.getCurrentPosition () there’s is no alert, there’s no error, there’s nothing, it simply does not respond.

Ehm, any more details? Doesn’t it work at all or just look ugly?

Using android, right? Just connect your phone via usb to your computer, enable remote debugging (https://developers.google.com/web/tools/chrome-devtools/remote-debugging/). Then execute “ionic run android -l -c”. ‘-l’ enables live reload on changes and ‘-c’ enables output to the command line of console.log().
Important: Check in windows hardware manager, if the phone is installed properly or if there are any driver issues. Took me a while myself the first time to realize the device simply did not install all required usb drivers when being connected to my PC.

Hi there. It’s not really clear what the issue/question is.
If you need to debug and read your console logs, deploy to your device through usb, open chrome, navigate to chrome://inspect and select your target.

This will give you the same dev tool as your browser, with element, console, and network tabs.

The problem is Geolocation never responds, when i try the app trough Web
Browser in my laptop it works very good, but when i execute the app in a ,
Device Geolocation not work.

Not look ugly, simply no asnwer from Geolocation

have you kept on your gps of mobile ? location

just try with enableHighAccuracy:false

Have you getting any error?? Check in settings->Aplications->App Admin -> your app->permissions if you have location permissions.

Hello Brother @wp1 Yes, it have…

Hello my friend, thank you for your time. same results, not answer, no alert, in this code

Geolocation.getCurrentPosition({enableHighAccuracy: false }).then((position) => {
  alert('position.coords.latitude: ' + position.coords.latitude);
}, (err) => {
  alert('ERROR(' + err.code + '): ' + err.message);

It’s just as if I did not call the Geolocation.getCurrentPosition () function, please take a look at today’s update, I need your help, thank you.

What did you finally do ?

A typical process for installing and using geolocation.

  1. Install the plugin at command line
ionic cordova plugin add cordova-plugin-geolocation —variable GEOLOCATION_USAGE_DESCRIPTION=“locating people”
// 2 dashes before variable
  1. Install npm package at command line
npm install —save @ionic-native/geolocation 
// 2 dashes before save. My cell-phone is smooshing them together 
  1. Add Geolocation to providers in app.module.ts
  2. In the component you want to use it in, import it
import { Geolocation } from ‘@ionic-native/geolocation’;
  1. In that components’ constructor
public geolocation: Geolocation,
  1. In a function on that component
this.geolocation.getCurrentPosition().then((position) => {

The problem may be that you’re referencing the import itself instead of a reference that you should be creating in your constructor.

Wrap that function in ionViewDidLoad also.

this.geolocation.getCurrentPosition etc...
// or whatever function is responsible for this.geolocation.getCurrentPosition()

I like to use


I’ve found that it’s better to downgrade the cordova plugin and then everything works !

npm install cordova-plugin-geolocation@2.4.3

Now i have the android geolocation working !!