收藏
回答

iOS 微信版本7.0.12 陀螺仪失效

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 个回答

  • 小程序技术专员-binnie
    小程序技术专员-binnie
    2020-03-27

    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" );
        }
    }
    


    2020-03-27
    有用 1
    回复 18
    • Evil
      Evil
      2020-03-27
      好的,谢谢
      2020-03-27
      回复
    • 胡大胖
      胡大胖
      2020-03-28回复Evil
      你好 请问你是怎么解决的呢 麻烦告知一下
      2020-03-28
      回复
    • 胡大胖
      胡大胖
      2020-03-28回复Evil
      谢谢  已经解决了
      2020-03-28
      回复
    • 奶茶要喝大杯的
      奶茶要喝大杯的
      2020-04-01回复胡大胖
      请问您是怎么解决ios13+版本以上无法触发摇一摇的问题呢?
      2020-04-01
      回复
    • 胡大胖
      胡大胖
      2020-04-01回复奶茶要喝大杯的
      需要一个按钮之类的调用授权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 )授权成功后就可以用了
      2020-04-01
      回复
    查看更多(13)
  • Alan
    Alan
    2020-04-17

    微信版本 7.0.11以下版本是不是不需要用户授权的呀?

    2020-04-17
    有用
    回复
登录 后发表内容
问题标签