navigator.geolocation.getCurrentPosition() never returns in WebView on Android

后端 未结 8 1242
萌比男神i
萌比男神i 2021-02-18 16:27

I am trying to access the HTML Geolocation API available in Android WebView (using SDK version 24).

The main problem is that the call to navigator.geolocat

8条回答
  •  离开以前
    2021-02-18 17:25

    For applications targeting Android N and later SDKs (API level > Build.VERSION_CODES.M), the method onGeolocationPermissionsShowPrompt (String origin, GeolocationPermissions.Callback callback) is only called for requests originating from secure origins such as HTTPS. On non-secure origins, geolocation requests are automatically denied.

    You could narrow down your problem by yourself if you had tried putting a breakpoint or a log inside the method.

    You have two options:

    1. Target a lower level API, which is obviously much easier but not really appreciated.
    2. Set up SSL in your website.

提交回复
热议问题