Capacitor: GeolocationPositionError

Hi all,

first of all, sorry - I know there are some threads on this topic with ionic 3. But as I’ve been googling the issue for quite some time, I’d really appreciate if you could help me out.

I’ve usually worked with ionic and cordova, mostly debugging on “emulate browser”. I’ve now moved to capacitor and the best debugging solution seems to be “ionic capacitor run android -l --external”.

My unsolved problem: I’m getting a GeolocationPositionError telling me that “Only secure origins are allowed”. Apparently, this seems to be an error related to ionic running on http instead of https.

I’m using both geolocation.getCurrentPosition() and geolocation.watchPosition() depending on the use-case.

Thanks a lot for your help. I’m pretty sure someone found a fix for that.

Ionic CLI : 6.12.3
Ionic Framework : @ionic/angular 5.5.2
Capacitor CLI & core : 2.4.5

Device: Tested on Android 10 and 11.

Looks like you are using the web version of the plugin instead of the native version. Web version requires https, but native version doesn’t as it uses native code.