my.vibrate triggers the device vibration. Use it for haptic feedback on button press or to get the user’s attention.
function vibrate() {
my.vibrate({
success: () => {
my.alert({ title: "Vibration on" });
},
fail: (err) => {
console.log("Vibrate failed", err);
},
});
}
| Property | Type | Required | Description |
|---|---|---|---|
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback function upon call completion (executed whether the call succeeds or fails). |