Javascript DeviceOrientationEvent.askPermission()未提示任何内容
我想通过电话访问加速计数据 在iOS 13中,您必须明确请求获得该数据的许可 我的开发安装程序正在运行Javascript DeviceOrientationEvent.askPermission()未提示任何内容,javascript,accelerometer,ios13,mobile-website,device-orientation,Javascript,Accelerometer,Ios13,Mobile Website,Device Orientation,我想通过电话访问加速计数据 在iOS 13中,您必须明确请求获得该数据的许可 我的开发安装程序正在运行webpack dev server,使用--https,在我的iPhone(iOS 13.3,Safari)上的本地网络上进行测试 我第一次调用checkOrientation()-当它在iOS上时返回true(例如,我的桌面客户端返回false) 如果checkOrientation()返回true,我将调用askOrientation()。此承诺调用DeviceOrientationEve
webpack dev server
,使用--https
,在我的iPhone(iOS 13.3,Safari)上的本地网络上进行测试
checkOrientation()
-当它在iOS上时返回true
(例如,我的桌面客户端返回false
)checkOrientation()
返回true
,我将调用askOrientation()
。此承诺调用DeviceOrientationEvent.requestPermission()
方法,然后if(response==“grated”)返回true代码>然后调用
window.addEventListener(“deviceorientation”,handleOrientation,true)代码>
DomeException{}
,没有更多信息。response=='grated'返回false,但在此之前我从未得到任何提示
以下是大部分代码:
exports.checkOrientation = function(){
console.log("PermissionsMgr asking Orientation");
if(typeof(DeviceOrientationEvent) !== 'undefined' && typeof (DeviceOrientationEvent.requestPermission) === 'function'){
//ios13
return true;
}else{
// not ios13
return false;
}
}
//如果checkOrientation()==true,那么我调用askOrientation():
问题:当我调用DeviceOrientationEvent.requestPermission()时,如何在我的移动设备上显示提示?您是否设法修复了它?
exports.askOrientation = function(){
DeviceOrientationEvent.requestPermission()
.then(response => {
if(response=='granted'){
hasGranted=true;
}else{
hasGranted=false;
}
return hasGranted;
})
.catch(console.error)
}