michael@0: michael@0: michael@0: # org.apache.cordova.vibration michael@0: michael@0: This plugin aligns with the W3C vibration specification http://www.w3.org/TR/vibration/ michael@0: michael@0: This plugin provides a way to vibrate the device. michael@0: michael@0: This plugin defines global objects including `navigator.vibrate`. michael@0: michael@0: Although in the global scope, they are not available until after the `deviceready` event. michael@0: michael@0: document.addEventListener("deviceready", onDeviceReady, false); michael@0: function onDeviceReady() { michael@0: console.log(navigator.vibrate); michael@0: } michael@0: michael@0: ## Installation michael@0: michael@0: cordova plugin add org.apache.cordova.vibration michael@0: michael@0: ## Supported Platforms michael@0: michael@0: navigator.vibrate,
michael@0: navigator.notification.vibrate michael@0: - Amazon Fire OS michael@0: - Android michael@0: - BlackBerry 10 michael@0: - Firefox OS michael@0: - iOS michael@0: - Windows Phone 7 and 8 michael@0: michael@0: navigator.notification.vibrateWithPattern,
navigator.notification.cancelVibration michael@0: - Android michael@0: - Windows Phone 8 michael@0: michael@0: ## vibrate (recommended) michael@0: michael@0: This function has three different functionalities based on parameters passed to it. michael@0: michael@0: ###Standard vibrate michael@0: michael@0: Vibrates the device for a given amount of time. michael@0: michael@0: navigator.vibrate(time) michael@0: michael@0: or michael@0: michael@0: navigator.vibrate([time]) michael@0: michael@0: michael@0: -__time__: Milliseconds to vibrate the device. _(Number)_ michael@0: michael@0: ####Example michael@0: michael@0: // Vibrate for 3 seconds michael@0: navigator.vibrate(3000); michael@0: michael@0: // Vibrate for 3 seconds michael@0: navigator.vibrate([3000]); michael@0: michael@0: ####iOS Quirks michael@0: michael@0: - __time__: Ignores the specified time and vibrates for a pre-set amount of time. michael@0: michael@0: navigator.vibrate(3000); // 3000 is ignored michael@0: michael@0: ####Windows and Blackberry Quirks michael@0: michael@0: - __time__: Max time is 5000ms (5s) and min time is 1ms michael@0: michael@0: navigator.vibrate(8000); // will be truncated to 5000 michael@0: michael@0: ###Vibrate with a pattern (Android and Windows only) michael@0: Vibrates the device with a given pattern michael@0: michael@0: navigator.vibrate(pattern); michael@0: michael@0: - __pattern__: Sequence of durations (in milliseconds) for which to turn on or off the vibrator. _(Array of Numbers)_ michael@0: michael@0: ####Example michael@0: michael@0: // Vibrate for 1 second michael@0: // Wait for 1 second michael@0: // Vibrate for 3 seconds michael@0: // Wait for 1 second michael@0: // Vibrate for 5 seconds michael@0: navigator.vibrate([1000, 1000, 3000, 1000, 5000]); michael@0: michael@0: ####Windows Phone 8 Quirks michael@0: michael@0: - vibrate(pattern) falls back on vibrate with default duration michael@0: michael@0: ###Cancel vibration (not supported in iOS) michael@0: michael@0: Immediately cancels any currently running vibration. michael@0: michael@0: navigator.vibrate(0) michael@0: michael@0: or michael@0: michael@0: navigator.vibrate([]) michael@0: michael@0: or michael@0: michael@0: navigator.vibrate([0]) michael@0: michael@0: Passing in a parameter of 0, an empty array, or an array with one element of value 0 will cancel any vibrations. michael@0: michael@0: ## *notification.vibrate (deprecated) michael@0: michael@0: Vibrates the device for a given amount of time. michael@0: michael@0: navigator.notification.vibrate(time) michael@0: michael@0: - __time__: Milliseconds to vibrate the device. _(Number)_ michael@0: michael@0: ### Example michael@0: michael@0: // Vibrate for 2.5 seconds michael@0: navigator.notification.vibrate(2500); michael@0: michael@0: ### iOS Quirks michael@0: michael@0: - __time__: Ignores the specified time and vibrates for a pre-set amount of time. michael@0: michael@0: navigator.notification.vibrate(); michael@0: navigator.notification.vibrate(2500); // 2500 is ignored michael@0: michael@0: ## *notification.vibrateWithPattern (deprecated) michael@0: michael@0: Vibrates the device with a given pattern. michael@0: michael@0: navigator.notification.vibrateWithPattern(pattern, repeat) michael@0: michael@0: - __pattern__: Sequence of durations (in milliseconds) for which to turn on or off the vibrator. _(Array of Numbers)_ michael@0: - __repeat__: Optional index into the pattern array at which to start repeating (will repeat until canceled), or -1 for no repetition (default). _(Number)_ michael@0: michael@0: ### Example michael@0: michael@0: // Immediately start vibrating michael@0: // vibrate for 100ms, michael@0: // wait for 100ms, michael@0: // vibrate for 200ms, michael@0: // wait for 100ms, michael@0: // vibrate for 400ms, michael@0: // wait for 100ms, michael@0: // vibrate for 800ms, michael@0: // (do not repeat) michael@0: navigator.notification.vibrateWithPattern([0, 100, 100, 200, 100, 400, 100, 800]); michael@0: michael@0: ## *notification.cancelVibration (deprecated) michael@0: michael@0: Immediately cancels any currently running vibration. michael@0: michael@0: navigator.notification.cancelVibration() michael@0: michael@0: *Note - due to alignment with w3c spec, the starred methods will be phased out