iOS 微信版本7.0.12 陀螺仪失效
访问链接:https://shellsvp.nn.cagoe.com/test.html
预期表现:不停刷新 deviceorientation 事件回调的 event.beta 以及下方输出 1
测试微信版本7.0.12 实际结果为 只输出了1,没有更新event.beta
微信版本 7.0.11 符合预期
iOS 微信版本7.0.12 陀螺仪失效
访问链接:https://shellsvp.nn.cagoe.com/test.html
预期表现:不停刷新 deviceorientation 事件回调的 event.beta 以及下方输出 1
测试微信版本7.0.12 实际结果为 只输出了1,没有更新event.beta
微信版本 7.0.11 符合预期
2 个回答
https://stackoverflow.com/questions/56514116/how-do-i-get-deviceorientationevent-and-devicemotionevent-to-work-on-safari
function permission () { if ( typeof( DeviceMotionEvent ) !== "undefined" && typeof( DeviceMotionEvent.requestPermission ) === "function" ) { // (optional) Do something before API request prompt. DeviceMotionEvent.requestPermission() .then( response => { // (optional) Do something after API prompt dismissed. if ( response == "granted" ) { window.addEventListener( "devicemotion", (e) => { // do something for 'e' here. }) } }) .catch( console.error ) } else { alert( "DeviceMotionEvent is not defined" ); } }
.then( response => {
// (optional) Do something after API prompt dismissed.
if ( response == "granted" ) {
window.addEventListener( "devicemotion", (e) => {
// do something for 'e' here.
})
}
})
.catch( console.error )授权成功后就可以用了
微信版本 7.0.11以下版本是不是不需要用户授权的呀?