Plugin vibration - CGastrell/phonegap GitHub Wiki
Ver documentacion
Buscar el plugin. Ubicar los repositorios de Apache y sus replicas en Github.
https://github.com/apache/cordova-plugin-vibration
phonegap plugin add ..\templates\org.apache.cordova.vibration
Editar el www/index.html
. Necesitamos identificar facilmente un boton para asignarle funcionalidad.
<button id="boton1" type="button" class="btn btn-block btn-default">Default</button>
<button id="boton1" type="button" class="btn btn-block btn-primary">Primary</button>
Editar el archivo www/js/index.js
y agregar una funcion al evento click
de #boton1
y #boton2
:
//...
onDeviceReady: function() {
app.receivedEvent('deviceready');
$('#boton1').on('click', function(){
navigator.vibrate(1000);
});
$('#boton2').on('click', function(){
navigator.vibrate([50,500,1000]);
});
},
//...
El plugin brinda un unico metodo para hacer vibrar el dispositivo: vibrate()
.
vibrate(ms): hara vibrar el dispositivo por ms
milisegundos. En Windows Phone el maximo es de 5000 (5 segundos). En iOS tendra un valor fijo de 3000 (3 segundos).
vibrate([ms, ms, ...]) (Android): si se provee un array de valores numericos correspondera a una secuencia del tipo:
- milisegundos vibrar, milisegundos de pausa, milisegundos vibrar... etc
Una vez hechos los cambios, volver a ejecutar:
phonegap run android