How can I find out if a device has a vibrator?

后端 未结 4 1104
臣服心动
臣服心动 2021-01-03 17:58

I have a device of which I don\'t know if it has a vibrator.

Is there a way to query for the availability of the vibrator?

4条回答
  •  半阙折子戏
    2021-01-03 18:12

    Maybe it'll help someone. Since I'm building a PWA, I ended up checking the screen size:

      if (window.innerWidth < 600) {
        window.navigator.vibrate(300);
      }
    

提交回复
热议问题