ask for geolocation permission again if it was denied

喜夏-厌秋 提交于 2019-12-28 05:56:09

问题


im building an app through phonegap, with a geolocation button.

if a user denies permission for geolocation the first time, how can i ask for permission again when they click the geolocation button again?

my code structure at the moment is:

function getLocation() {    
    if(navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition, positionError);

    } else {
        hideLoadingDiv()
        showError('Geolocation is not supported by this device')
    }
}

function positionError() {
    hideLoadingDiv()
    showError('Geolocation is not enabled. Please enable to use this feature')
}

回答1:


You can't.

The only thing you can do is to display the instructions to reactivate the location sharing in his browser's settings (https://support.google.com/chrome/answer/142065?hl=en).



来源:https://stackoverflow.com/questions/20678707/ask-for-geolocation-permission-again-if-it-was-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!