在iOS 13中,苹果引入了DeviceOrientationEvent.requestPermission接口。它必须在用户操作(点击、点击或等效操作)时触发。我这里的问题是,结果似乎是缓存的,所以如果用户拒绝权限,我就不能再次请求访问(承诺会自动使用缓存值实现)。有没有办法强制设备忘记缓存值,并再次请求用户访问方向数据的权限(我的意思是,它应该再次显示弹出窗口,用户可以在其中允许或拒绝访问)?
相关代码如下:
if (DeviceOrientationEvent && typeof(DeviceOrientationEvent.requestPermission) === "function") {
const permissionState = await DeviceOrientationEvent.requestPermission();
if (permissionState === "granted") {
// Permission granted
} else {
// Permission denied
}
}发布于 2020-02-15 22:43:19
尝试简单地退出Safari并重新启动它。提示符将返回。
发布于 2019-09-30 18:13:59
我在iOS 13Safari上看到了同样的行为。您需要删除需要权限的特定网站的网站数据。进入设置> Safari >高级>网站数据,查找网站并删除所有数据。然后,当您请求权限时,提示应该会再次出现。
发布于 2019-09-25 04:32:51
你确定这是缓存问题吗?我不能让iOS 13中的隐姓埋名的Safari回复一个“授予的”许可。我马上就收到了“拒绝”的回复--没有提示。
我使用以下代码来测试结果,但它总是被立即“拒绝”,而不显示提示事件。(https://codepen.io/ejarnutowski/pen/WNePqmM)
<button onclick="testDeviceOrientation()">Test Device Orientation</button>function testDeviceOrientation() {
if (typeof DeviceOrientationEvent !== 'function') {
return setResult('DeviceOrientationEvent not detected')
}
if (typeof DeviceOrientationEvent.requestPermission !== 'function') {
return setResult('DeviceOrientationEvent.requestPermission not detected')
}
DeviceOrientationEvent.requestPermission().then(function(result) {
return setResult(result);
});
}
function setResult(result) {
document.getElementById('result').innerHTML = 'RESULT: ' + result;
}看起来drawmote.app可以正常工作,但是JS是编译的,我需要一段时间来逆向设计他们的逻辑。
https://stackoverflow.com/questions/58084703
复制相似问题