my.vibrate(OBJECT)
This API is supported in mPaaS 10.1.60 and later versions.
This API is used to call the vibration function.
Code sample
// API-DEMO page/API/vibrate/vibrate.json{"defaultTitle": "Vibrate"}
<!-- API-DEMO page/API/vibrate/vibrate.axml--><view class="page"><button type="primary" onTap="vibrate">Start vibrating</button><button type="primary" onTap="vibrateLong">Long vibration (400ms)</button><button type="primary" onTap="vibrateShort">Short vibration (40ms)</button></view>
// API-DEMO page/API/vibrate/vibrate.jsPage({vibrate() {my.vibrate({success: () => {my.alert({ title: 'Vibrating'});}});},vibrateLong() {if (my.canIUse('vibrateLong')) {my.vibrateLong((res) => { });} else {my.alert({title: 'Client version is too low',content: 'my.vibrateLong() requires 10.1.35 and later versions'});}},vibrateShort() {if (my.canIUse('vibrateShort')) {my.vibrateShort((res) => { });} else {my.alert({title: 'Client version is too low',content: 'my.vibrateShort() requires 10.1.35 and later versions'});}}});
my.vibrateLong(OBJECT)
This API is supported in mPaaS 10.1.60 and later versions.
Long vibration (400 ms).
Code sample
// API-DEMO page/API/vibrate/vibrate.json{"defaultTitle": "Vibrate"}
<!-- API-DEMO page/API/vibrate/vibrate.axml--><view class="page"><button type="primary" onTap="vibrate">Start vibrating</button><button type="primary" onTap="vibrateLong">Long vibration (400ms)</button><button type="primary" onTap="vibrateShort">Short vibration (40ms)</button></view>
// API-DEMO page/API/vibrate/vibrate.jsPage({vibrate() {my.vibrate({success: () => {my.alert({ title: 'Vibrating'});}});},vibrateLong() {if (my.canIUse('vibrateLong')) {my.vibrateLong((res) => { });} else {my.alert({title: 'Client version is too low',content: 'my.vibrateLong() requires 10.1.35 and later versions'});}},vibrateShort() {if (my.canIUse('vibrateShort')) {my.vibrateShort((res) => { });} else {my.alert({title: 'Client version is too low',content: 'my.vibrateShort() requires 10.1.35 and later versions'});}}});
my.vibrateShort(OBJECT)
This API is supported in mPaaS 10.1.60 and later versions.
Short vibration (40 ms).
Code sample
// API-DEMO page/API/vibrate/vibrate.json{"defaultTitle": "Vibrate"}
<!-- API-DEMO page/API/vibrate/vibrate.axml--><view class="page"><button type="primary" onTap="vibrate">Start vibrating</button><button type="primary" onTap="vibrateLong">Long vibration (400ms)</button><button type="primary" onTap="vibrateShort">Short vibration (40ms)</button></view>
// API-DEMO page/API/vibrate/vibrate.jsPage({vibrate() {my.vibrate({success: () => {my.alert({ title: 'Vibrating'});}});},vibrateLong() {if (my.canIUse('vibrateLong')) {my.vibrateLong((res) => { });} else {my.alert({title: 'Client version is too low',content: 'my.vibrateLong() requires 10.1.35 and later versions'});}},vibrateShort() {if (my.canIUse('vibrateShort')) {my.vibrateShort((res) => { });} else {my.alert({title: 'Client version is too low',content: 'my.vibrateShort() requires 10.1.35 and later versions'});}}});