Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova vibrate is not working

I'm running Cordova on Android and this is my config files.

config.xml

<feature name="Vibration">
    <param name="android-package" value="org.apache.cordova.vibration.Vibration" />
</feature>
<feature name="Media">
    <plugin name="Media" value="org.apache.cordova.AudioHandler" />
</feature>
<feature name="Notification">
    <param name="android-package" value="org.apache.cordova.Notification" />
</feature>

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />

my js

navigator.vibrate(1000);

I use normal jQuery (Not jQueryMobile) to run with cordova.
Vibration plugin as already installed by command line from this page (plugin git).

But vibration is not working.

like image 426
vee Avatar asked Oct 27 '14 20:10

vee


2 Answers

I know this is an old thread, but, when testing on a device, be sure that the device is un-muted. Many (most) devices will "mute" the vibration as well as the audio. If you are debugging in the browser, you should see 'Vibrating for 1000ms.' in the console, which tells you the plugin is working (obviously you can't vibrate your computer). But, again, when testing on a device, be sure it's not on mute.

like image 119
John Shipp Avatar answered Oct 16 '22 08:10

John Shipp


  • feature lines in config.xml are only usefull if you use phonegap build, you don't need it if you build using the CLI
  • you should not update androidmanifest directly, it's updated when you install the plugin.
  • maybe try navigator.notification.vibrate(1000)? (it's supposed to be deprecated but it's working for me)
like image 1
QuickFix Avatar answered Oct 16 '22 07:10

QuickFix