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

后端 未结 8 1247
萌比男神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:23

    There is an extensive post on this subject:

    navigator.geolocation.getCurrentPosition sometimes works sometimes doesn't

    Apparently the solution is to check on navigator.geolocation then make the call:

    if(navigator.geolocation) { // dummy call
        navigator.geolocation.getCurrentPosition(success, error)
    }
    

提交回复
热议问题