最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Chrome for Android: Vibrate API - Stack Overflow

programmeradmin2浏览0评论

When trying to use the Vibrate API in Chrome for Android (tested stable version 43 and dev version 45), it never vibrates. Using the simplest code:

window.navigator.vibrate(200);

When ran from the Javascript console, it returns true. Vendor prefixes don't fix it. The Chrome Status website shows the API was implemented in version 32. This code works in Firefox for Android. Is this a problem with Chrome or a problem with my code?

When trying to use the Vibrate API in Chrome for Android (tested stable version 43 and dev version 45), it never vibrates. Using the simplest code:

window.navigator.vibrate(200);

When ran from the Javascript console, it returns true. Vendor prefixes don't fix it. The Chrome Status website shows the API was implemented in version 32. This code works in Firefox for Android. Is this a problem with Chrome or a problem with my code?

Share Improve this question edited May 20, 2024 at 0:58 Cornelius Roemer 7,9493 gold badges52 silver badges100 bronze badges asked Jun 26, 2015 at 22:19 Isiah LIsiah L 4875 silver badges21 bronze badges 1
  • Strange,I tested this now and it works fine on stable, beta and dev chrome for android, it's not the problem with code or chrome(on my device). – Blago Eres Commented Jun 26, 2015 at 22:30
Add a comment  | 

3 Answers 3

Reset to default 15

Stupid me, Chrome For Android follows what sound profile you are currently on. While Firefox does not. So to feel vibrations your sound profile must be on vibrate or above.

Chrome vibration api won't work if your Android phone were using specific settings, including but not limited to:

  • Silent Mode: on
  • Do Not Disturb: on
  • Power Saving Mode: on
  • Vibration & Touch Feedback: disabled

In addition to vibrations not being disabled through Do not disturb etc, on Android 14 (Pixel), it is required to have "Touch feedback" not set to off (it's a slider) in: Settings > Vibration & haptics > Interactive haptics > Touch feedback

发布评论

评论列表(0)

  1. 暂无评论