NgCordova + Vibrate

Hello !

I’m trying to make the vibration work, but I don’t know why it doesn’t.
I always have : Uncaught TypeError: Cannot read property 'vibrate' of undefined

It’s on my phone, not in browser (I don’t want to shake my window :smile:)

I’ve included ng-cordova.js in my head of index.html

<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/ngCordova/ng-cordova.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

in my app.js

angular.module('xxxx', ['ngCordova', 'ionic','xxx.controllers', '', 'xxx.filters', 'xxx.directives'])

and my AuthController.js

	.controller('AuthController.index', ["$scope", "$ionicPlatform", "$state", "$ionicSideMenuDelegate", "$window", "$cordovaVibration",
		function($scope, $ionicPlatform, $state, $ionicSideMenuDelegate, $window, $cordovaVibration) {
			// Vérification que la personne est loguée
			if ($window.sessionStorage['token']) {
			$ionicPlatform.ready(function() {
				console.log("i'm ready");

What I really don’t understand is why it works with the toast, but not the vibrate… :confused:

Hope you can help me


Have you included the actual cordova plugin?


It was indeed the problem. My real error was with the Cordova App Preference plugin, which doesnt work at all for me.

I’ve same problem, but the error is not exactly like yours: TypeError: $cordovaVibration.vibrate is not a function

        $scope.addProductToCard = function (product) {
            if ($scope.platform.isWebView()) {