Feature Request: Expose iOS haptics to card JavaScript

I was wondering if it would be possible for AnkiMobile to expose a very small native haptics function to JavaScript within card templates.

My understanding is that navigator.vibrate() can work on Android, but WebKit on iOS does not support the Vibration API, so there currently isn’t a way for HTML/JavaScript in an Anki card to trigger the iPhone’s haptic feedback.

I saw the older feature request for a broader JavaScript API for AnkiMobile, and Damien’s response at the time that supporting a general API wasn’t feasible. I was wondering whether a much narrower feature might be more manageable.

For example, something along the lines of:

anki.haptic(“light”)
anki.haptic(“medium”)
anki.haptic(“success”)

Or even just a single basic haptic function.

My particular use case is gamifying reviews. I have an Anki add-on on desktop that provides haptic feedback for things like answering cards and running out of time, and I’d like to be able to reproduce some of that behavior through the card template when reviewing on iPhone.

I could also see this being useful for interactive cards, correct/incorrect feedback, timers, and potentially accessibility.

I’m not suggesting exposing arbitrary native iOS functionality to card JavaScript, just wondering whether a small, intentionally limited haptics bridge would be technically reasonable for AnkiMobile.

2 Likes