是否可以检查是否已授予 DeviceMotionEvent 权限?以及我们如何将请求警报文本从“本地主机想要访问运动和方向”更改为“应用程序名称想要访问运动和方向”?
public requestDeviceMotion() {
if typeof (DeviceMotionEvent as any).requestPermission === 'function') {
(DeviceMotionEvent as any).requestPermission()
.then(permissionState => {
if (permissionState === 'granted') {
window.addEventListener('devicemotion', () => { });
}
})
.catch(console.error);
} else {
// handle regular non iOS 13+ devices
console.log("not iOS");
}
}