Android 没有给出 Geolocation ionic 4

Android not giving Geolocation ionic 4

我正在使用来自@ionic-native/geolocation/ngx 的地理定位来显示用户在查看传单地图时的位置,我的代码适用于我的浏览器和 IOS 手机(我 运行 ionic服务 --devapp).

我从 Android 部电话中收到错误消息,这些电话为“[object GeolocationPositionError]”,错误消息为 "Only secure origins are allowed (see: goo.gl/Y0ZkNV)."。有人可以帮我吗?

此外,该应用程序会自动请求使用 GPS 的权限,我的应用程序中还没有请求权限的代码。

this.geolocation.getCurrentPosition().then((resp) => {
         resp.coords.latitude;
         resp.coords.longitude;
         let marker = L.marker([resp.coords.latitude, resp.coords.longitude]).addTo(this.map)
           .bindPopup('Your Location')
           .openPopup();
         this.map.setView([resp.coords.latitude, resp.coords.longitude], 15);
         console.log(resp.coords.latitude+" "+ resp.coords.longitude);
       }).catch((error) => {
         console.log('Error getting location ', error);
});

我是否需要做任何其他事情才能使代码适用于 Android?

非常感谢:)

当使用 cordova 或 capcitor for Ionic 4 将应用程序部署到设备上时,华为设备将提供地理定位,但它不适用于 ionic serve --devapp。