PositionError while using geolocation plugin on android device


I am using ionic native plugin cordova-plugin-geolocation in my app for retrieving device’s current location. Below is my approach after installing plugin-

import { Geolocation } from ‘@ionic-native/geolocation’;
constructor(private geolocation: Geolocation) {}
this.geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
}).catch((error) => {
console.log(‘Error getting location’, error);

I am able to retrieve co-ordinates on iOS and browser. But it is not working on android device which is returning “object PositionError”. It used to work earlier on android device also. Suddenly I am getting this error. Could some one please help me in getting this resolved?


PositionError has a code and a message that should tell you more: https://ionicframework.com/docs/native/geolocation/#PositionError

Hi @Sujan12, I am getting error code 1 and error message “Only secure origins are allowed (see: https://goo.gl/Y0ZkNV)”.

How exactly are you testing this?
How are you building and running your app?

it doesn’t work with --livereload