Bil*_*ull 9 javascript geolocation mobile-safari ios
当geolocation.getCurrentPosition在移动设备(目前已测试 iOS)上使用 API 时,根据页面的不同,用户会在会话中多次收到提示。与桌面网站(例如 Windows 10 上的 Chrome)相比,一旦用户点击,Allow将不再提示他们提供权限,除非明确禁用。iOS Safari 似乎是基于会话的,然后可能是基于会话内的页面?
想知道是否有人知道Apple对此权限检查是否定义了明确的规则?maximumAge提示用户的频率也有影响吗?
const LOCATION_OPTIONS = {
timeout: 15000,
enableHighAccuracy: true,
maximumAge: 86400000,
};
useEffect(() => {
const { geolocation } = navigator;
// If the geolocation is not defined in the used browser we handle it as an error
if (!geolocation) {
setError("Geolocation is not supported.");
return;
}
// Call Geolocation API
geolocation.getCurrentPosition(handleSuccess, handleError, options);
}, [options]);
return { location, error };
Run Code Online (Sandbox Code Playgroud)
NextJS CodeSandbox 示例 https://u11vn.sse.codesandbox.io/
| 归档时间: |
|
| 查看次数: |
2671 次 |
| 最近记录: |