Geolocation : Ionic V3: Android problem Only secure origins are allowed


#1

The geolocation is not working on android, I always get the same message, using ionicdevapp + ionic serve -c and also ionic cordova run android on an android device, everything works well on IOS, some idea of how to solve the problem? I have read some forums but it is not clear to me if there is any solution.

Example code :

getPosition():any{
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};

this.geolocation.getCurrentPosition(options).then(response => {
  console.log('OK'); 
  

})
.catch(error =>{
  console.log("Error="+ error.code +" =>"+ error.message);
})

}

Error=1
Only secure origins are allowed (see: https ://goo.gl/Y0ZkNV).

Ionic:

ionic (Ionic CLI) : 4.2.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.5, (and 12 other plugins)

System:

Android SDK Tools : 26.1.1 (/usr/local/Android/Sdk/)
NodeJS : v8.10.0 (/usr/bin/node)
npm : not installed
OS : Linux 4.15