解决ios13摇一摇不能触发

代码如下

permissionForShake() {
      if (typeof DeviceMotionEvent.requestPermission === ‘function‘) {
        DeviceMotionEvent.requestPermission()
          .then(permissionState => {
            if (permissionState === ‘granted‘) {
              window.addEventListener(‘devicemotion‘, () => {})
            }
          })
          .catch(err => {
            console.log(err)
          });
      } else {
        console.log(22222)
        // ios其他系统可以不通过请求直接摇一摇
      }
    }
permissionForShake这个方法必须需要用户点击才能触发,js代码不能触发

解决ios13摇一摇不能触发

上一篇:IOS添加ZXing库实现二维码功能简述d


下一篇:RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.