iOS 微信版本7.0.12 陀螺仪失效
发布于 6 年前 作者 uliang 13077 次浏览 来自 官方Issues

iOS 微信版本7.0.12  陀螺仪失效

访问链接:https://shellsvp.nn.cagoe.com/test.html

预期表现:不停刷新 deviceorientation 事件回调的 event.beta 以及下方输出 1

测试微信版本7.0.12 实际结果为 只输出了1,没有更新event.beta

微信版本 7.0.11 符合预期

1 回复

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" );
    }
}
回到顶部