Local notification onclick don't work

I succesfully use ngCordova notification to make localnotification when user recive new message:

.controller('checkNew', function($scope, getNewMsg, $localstorage, $cordovaLocalNotification, $http, $state) {
     getNewMsg.getNew(function(data) {$scope.counter = data; if(data!=0){$scope.addNotification(data)}});
     
     $scope.addActivity = function (msg) {
         $cordovaLocalNotification.add({
             id: '1',
             message:    'Uno speeder ha aggiunto una nuova attività che ti coinvolge!',
             title:      'Nuova attività aggiunta',  // The title of the message
             }).then(function(){$scope.clickAct; $scope.cancelAllNotification});
             };
             
     $scope.addNotification = function (msg) {
         $cordovaLocalNotification.add({
             id: '1',
             message:    'Hai ricevuto '+msg+' messaggi!',
             title:      'Nuovo messaggi in archivio',  // The title of the message
             }).then(function(){$scope.clickMsg;$scope.cancelNotification});
             };
    $http.post('http://www.digitalxp.it/appwork/include/check_act.asp?username='+$localstorage.get('name')).success(function(data){if(data!=0){$scope.addActivity()}}).error(function(){alert("Errore di comunicazione!")});
  $scope.cancelNotification = function () {
    $cordovaLocalNotification.cancel('1').then(function () {
      console.log('callback for cancellation background notification');
    });
  };
  $scope.clickMsg = function () {
    $cordovaLocalNotification.onclick().then(function () {
        $state.go('app.messaggi');
          console.log('Cambio view');
    });
  };
  $scope.clickAct = function () {
    $cordovaLocalNotification.onclick().then(function () {
        $state.go('app.attivita');
          console.log('Cambio view');
    });
  };
  $scope.cancelAllNotification = function () {
    $cordovaLocalNotification.cancelAll().then(function () {
      console.log('callback for canceling all background notifications');
    });
  };
})

but when I click on the notification nothing happen! I would go to message page or activity page!
What’s wrong?

Ok I solve so, for everyone who want to use:

.run(function($ionicPlatform,$cordovaLocalNotification,$rootScope) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);}
    if(window.StatusBar) {StatusBar.styleDefault();}
	$cordovaLocalNotification.hasPermission().then(function(granted) {
      $cordovaLocalNotification.cancelAll();
      if (!granted) {$cordovaLocalNotification.promptForPermission()};
    });
    document.addEventListener("deviceReady", function() {
      // Event handling for Local Notifications
      window.plugin.notification.local.onclick = function(id, state, json) {
		  $rootScope.$broadcast('onNotificationClick', id, state, json);
      };
    });
  });
})

and this in controller:

$scope.addNotification = function (message) {
		 $cordovaLocalNotification.add({id:'2',message:'Hai ricevuto '+message+' messaggi!',title:'Nuovo messaggi in archivio'}).then(
		 function(){console.log('hai cliccato')}) 
	};
	

    $scope.$on('onNotificationClick', function(event, id, state, json) {
		console.log('hai cliccato e apre...');
		$state.go('app.messaggi');
		$cordovaLocalNotification.cancelAll();
		console.log('Ora cancello...');
		}) 


  $scope.cancelAllNotification = function () {
    $cordovaLocalNotification.cancelAll().then(function () {
      console.log('callback for canceling all background notifications');
    });
  };

for local notification plugin we need any further backgroud or foreground plugins to be added??

because notification recieved successfully but event is not working

only when app is in foreground, $state.go or alert or anything else works, but when its in background nothing happens, only main page of app loads.
Has anyone any idea about it? how can i send the user to a specific page when he clicks on notification when app is in background?