isSupported checks for navigator.vibrate (Vibration API), which iOS Safari doesn't implement, so it returns false on iOS. But .trigger() still fires haptics on iOS via the <input type="checkbox" switch> fallback you've built in.
Discovered this when I wanted to provide a toggle for enabling haptics in my app, expecting this toggle to not be shown in the desktop version.
if (WebHaptics.isSupported) showHapticsToggle(); // This hides on iOS Safari, even though haptics work
To me, isSupported is more of a check on whether the Vibration API is supported, rather than haptics are supported on the device.
Would you be open to amending isSupported or adding like a canHaptic property that covers both paths?
static readonly canHaptic =
typeof navigator !== "undefined" &&
(typeof navigator.vibrate === "function" || navigator.maxTouchPoints > 0);
navigator.maxTouchPoints > 0 is true on iOS and Android, false on desktop, matching the environments where haptics actually fire.
Happy to open a PR if this direction makes sense to you.
isSupportedchecks for navigator.vibrate (Vibration API), which iOS Safari doesn't implement, so it returns false on iOS. But .trigger() still fires haptics on iOS via the<input type="checkbox" switch>fallback you've built in.Discovered this when I wanted to provide a toggle for enabling haptics in my app, expecting this toggle to not be shown in the desktop version.
if (WebHaptics.isSupported) showHapticsToggle(); // This hides on iOS Safari, even though haptics workTo me,
isSupportedis more of a check on whether the Vibration API is supported, rather than haptics are supported on the device.Would you be open to amending
isSupportedor adding like acanHapticproperty that covers both paths?navigator.maxTouchPoints > 0is true on iOS and Android, false on desktop, matching the environments where haptics actually fire.Happy to open a PR if this direction makes sense to you.