Device Vibration
The vibration bridge lets your website make the device vibrate on demand. You can trigger a simple one-shot vibration with a set duration, or define a custom pattern of alternating wait and vibrate intervals for more expressive feedback.
Simple Vibration
javascript
appilix.postMessage(JSON.stringify({
type: "vibrate",
props: {
duration: 300
}
}));If duration is omitted, the device vibrates for 200ms by default.
Pattern Vibration
javascript
appilix.postMessage(JSON.stringify({
type: "vibrate",
props: {
pattern: [0, 1000, 500, 200]
}
}));The pattern array alternates between wait and vibrate durations in milliseconds:
[wait, vibrate, wait, vibrate, ...]So [0, 1000, 500, 200] means: start immediately → vibrate 1s → wait 500ms → vibrate 200ms.
When pattern is provided, duration is ignored.
Parameters
| Parameter | Type | Description |
|---|---|---|
duration | number | Vibration duration in milliseconds. Defaults to 200 if omitted. Ignored when pattern is provided. |
pattern | number[] | Alternating wait/vibrate durations in ms: [wait, vibrate, wait, vibrate, ...]. Takes priority over duration. |
Example: Vibrate on Form Submit
javascript
document.querySelector('#submit-btn').addEventListener('click', function () {
if (typeof appilix === 'undefined') return;
appilix.postMessage(JSON.stringify({
type: "vibrate",
props: { duration: 100 }
}));
});Example: Error Feedback Pattern
javascript
function vibrateError() {
if (typeof appilix === 'undefined') return;
appilix.postMessage(JSON.stringify({
type: "vibrate",
props: {
pattern: [0, 100, 100, 100, 100, 100]
}
}));
}This produces three short bursts — a common pattern for indicating an error or failed action.
For module setup and enabling the feature, see the Custom Vibration configuration article.