How to solve Only secure origins are allowed

Viewed 12262

I am using cordova geolocation plugin in Ionic app . when i ran the app inside emulator i found this bug Only secure origins are allowed . hence was unable to get the geolocation of inside emulator . but using locahost it works fine probably localhost comes under secure origin.

browser im using is chrome. plugin https://ionicframework.com/docs/native/geolocation/

3 Answers

For private IP address access, the latest Firefox seems to work out of the box (version 47.0 and above). If it does not work, go to about:config and set the media.navigator.permission.disabled to false. It's work for android too.

The problem is that the default web view scheme for Android is: http://localhost The geolocation plugin does not accept "http://..." as origin for position requests. On iOS it works because the default scheme is ionic://localhost

Set the Android Scheme to "https" in the config.xml file:

<preference name="Scheme" value="https" />

NB: it is necessary to allow also the navigation for the new scheme:

<allow-navigation href="https://*"/>

Other web view configurations: https://github.com/ionic-team/cordova-plugin-ionic-webview

Related