Ionic hybrid app geolocation blocked on iOS10

2019-07-04 03:28发布

问题:

Since iOS 10 came out and I updated my iPhone 6 navigator.geolocation.getCurrentPosition() is not working.
Address and port: 192.168.0.16:8100

Since geolocation API is considered as unsecured origin it would work only with SSL but can I do it in a Hybrid application where I don't know what will be the address on each phone?

I've already tried what's mentioned here: Geolocation is blocked in iOS10

  • Editing in XCode was not helping
  • Editing the Info.plist in text editor was not helping

I have Cordova White List plugin istalled and I'm using this not recommended wildcard in my config.xml: <allow-navigation href="*"/> .

It works fine on android and was working fine on iPhone 6 before the iOS update.

回答1:

The problem is you are using live reload, when you use live reload the app code is served from a local web server on your computer using http:// protocol.

If you don't use live reload the code will be loaded from inside your app using file:// protocol and geolocation will work.

Consider sending a bug report to ionic so they maybe can change the local server to serve the code through https