vee
vee

Reputation: 4755

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.

Upvotes: 7

Views: 6575

Answers (3)

Ajit Kumar
Ajit Kumar

Reputation: 1505

You need to add permission (android.permission.VIBRATE).

Upvotes: 0

John Shipp
John Shipp

Reputation: 1153

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.

Upvotes: 16

QuickFix
QuickFix

Reputation: 11721

  • 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)

Upvotes: 1

Related Questions