iOS 12.2+ 与 iOS 13 h5相关兼容问题

  1. DeviceMotionEvent & DeviceOrientationEvent
    最近同事的项目遇到iOS上无法开启重力感应的问题。经查是iOS对于重感事件的限制。
    需要如下操作让用户授权:
// 判断系统
if (typeof DeviceMotionEvent.requestPermission === 'function') {
  // iOS 13+
} else {
  // non iOS 13+
}

// 事件授权
DeviceMotionEvent.requestPermission()
.then(response => {
  if (response == 'granted') {
    window.addEventListener('devicemotion', (e) => {
      // do something with e
    })
  }
})
.catch(console.error)

DeviceOrientationEvent.requestPermission()
.then(response => {
  if (response == 'granted') {
    window.addEventListener('deviceorientation', (e) => {
      // do something with e
    })
  }
})
.catch(console.error)

tips: 授权事件需要手动触发(点击事件等)

  1. input 相关
    iOS12会在键盘弹出时将页面上推,并压缩body的高度。
    iOS13会在键盘弹出时将页面上推,但html,body的高度全部不变。
    摘自 https://www.cnblogs.com/pomelott/p/11568011.html
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容