Haptic Feedback API
Trigger native haptic feedback (vibrations) from your web app for a truly native app feeling on iOS.
Last updated:
WebViewGold allows for the implementation of native iOS haptic control within your web app. Using our API, you are able to perform the following actions:
We suggest previewing Apple's best practices overview before including these features into your application. An example of how this API can be utilised can be seen below, with an anchor tag and custom javascript function which interact with our haptic API.
<a onclick="lightHaptic('index.html')">Navigation Link with Haptics</a>
<script>
function lightHaptic(url) {
if (isWebViewBrowser) {
window.location.href = url;
loadInnerHref("lighthaptic://");
} else {
window.location.href = url;
}
}
function loadInnerHref(url) {
iFrame = document.createElement("iframe");
iFrame.setAttribute("src", url);
document.body.appendChild(iFrame);
iFrame.parentNode.removeChild(iFrame);
iFrame = null;
}
</script>
View the haptic feedback demo page. Inspect the page to view the example code.