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?