Check if localnotification already exist

Dear friends I made a interval http calling to check if a user recive new msg avery 5 sec.
When a new msg is founded I add a localnotification.

All works fine, but the problem is that the add localnotification if fired each time (if the user dont see the msg!).

So i think to make this:

messageService.getNew(function(data) {
		if(data.msg!=0){
			$scope.check(data.msg);
			$rootScope.counter = data.msg;
			console.log("Check if there are news msg");
			} else {
			$rootScope.counter = null;
			$scope.cancelAllNotification;
			}
		});
	//IF THERE ARE NEW MSG I CHECK IF EXISTS A NOTIFICATION
	$scope.check = function (data) {
		$cordovaLocalNotification.isScheduled('2').then(
		function(isScheduled) {
			console.log("Notifiche:"+isScheduled);
			if(isScheduled != true){$scope.addNotification(data)}
		}
	)};

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

but the notification is added each 5 sec!!!
Where is the error?!

Hi @digitalxp,

Try this one,

cordova.plugins.notification.local.isPresent(2,function(isScheduled){ 
     $cordovaLocalNotification.isScheduled('2').then(
	function(isScheduled) {
		console.log("Notifiche:"+isScheduled);
		if(isScheduled != true){$scope.addNotification(data)}
	} 
})

It works for me…