phonegap geolocation always fail on timeout

前端 未结 11 736
遥遥无期
遥遥无期 2020-12-06 01:06

I\'m using sencha-touch 2.0 and phonegap 2.0.0 in my app to retrieve user\'s location. When runing on my locahost, everything works just fine. However, when loading the .apk

11条回答
  •  忘掉有多难
    2020-12-06 01:42

    I know that maybe it is too late, but today i struggled with the same issue! The solution turned out to be very simple!

    SOLUTION: Reboot the device.

    That's all.

    The problem is, that you never know when i user will get this kind of bug, so if your application relies heavily on geolocation i recommend you set a timeout in location options navigator.geolocation.getCurrentPosition(geoSuccess, geoError, {timeout: 15000}) and alert user about the problem and possible solution.

    P.S. Keep in mind, that Geolocation can timeout for example if mobile data is turned off too, so reboot won't always fix it. On iPhone it uses cellular data to get your position, but on Android, it looks like the phone does not have access to cellular data unless 3G is turned on

提交回复
热议问题