I m building Android app in Ionic2 and Cordova i m using native Geolocation and google maps. Geo location in browser works well but when i run it on android I’m get flowing error: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV).
Here is code:
Geolocation.getCurrentPosition(options).then((position) => {
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
this.initMapFinished(latLng);
},function(err){console.log("ERROR: " + err.message)});
It’s a new secure procedure from google, Geolocation is only allowed from HTTPS and no longer supports HTTP. But i just couldn’t find a way to make it work. Can you help ?
An update on this is that for a signed production Android release the problem does not exist, so it’s only affecting the development build.
Also it’s only a problem when using live reload, if just doing “ionic run android” there is no error.
Google regard “localhost” as secure, but others as not.
I think it’s something to do with the fact that when the android build is connecting back to the dev machine, it has to do so on an IP address, so something other than localhost.
I think it’s this that is causing the problem.
@fdambrosio… You need run the app witthout --livereload, this is the problem, because when you use that flat, your app is not using the native components. I had the same issue.