Geo-location on Ionic np Android cause error: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV)

2

I'm using the plugin:

Within the project I created a simple example:

home.html

My Location

home.ts

//Chamado por um botão
start()
{
    this.geolocation.getCurrentPosition(opts).then((resp: any) => {
        console.log("latitude:", resp.coords.latitude);
        console.log("longitude:", resp.coords.longitude);
    }).catch((err: any) => {
        console.log('ERRO:', err.message);
        console.log('Code:', err.code);
    });
}

In iOS it works perfectly, console.log emits something like:

latitude: -0000000000
longitude: -0000000000

In Android neither error message, I receive even a Timeout message, only an empty object:

ERRO: Only secure origins are allowed (see: ...)
code: 1

I'm testing the App on an actual Android device (I tested it on more than one device) by installing the APK manually and in "Settings & Location" the application appears as allowed.

  

I am NOT using liveload

How do I solve this problem?

    
asked by anonymous 10.12.2018 / 20:17

1 answer

0

This problem has already occurred to me, I've decided to upgrade to a newer version.

ionic plugin rm cordova-plugin-geolocation

ionic plugin rm cordova-plugin-geolocation@latest --save

Another possible solution is to not use --livereload in run.

Finally you can try editing the AndroidManifest.xml with the following.

 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    
10.12.2018 / 20:23