How to check local notification exist or not


#1

Hi
I have made

      addalarm(){
    	  var alarmarray=["2016-06-03 20:59:00","2016-06-03 21:02:00","2016-06-03 21:08:00","2016-06-03 21:10:00"];
    	  for(var i=0;i<4;i++){
        var alarmtime = Date.parse(alarmarray[i]);
    cordova.plugins.notification.local.schedule({
    	id:i ,
        text: "Ramadan Notification",
        at: alarmtime,
        led: "FF0000",
        sound: "file://sound.mp3"
    });
      }
      }

it works fine. Now I want that the button for calling alarm function if there is no notification sets. How can I do that.

isScheduled function how to do I cant understand. Plz help me


#2
  checkalarm(){
	       cordova.plugins.notification.local.isScheduled("1").then(function(isScheduled) {
            alert("Notification 1234 Scheduled: " + isScheduled);
        });
    }

I have used above code to check. But When I click button to call this function, its not working.


#3

You might want to check out the dox for Local Notifications:


#4

thnx. I have checked already and on that basis I have written the code what I have replied earlier. But it is not working.
in the doc it says that isScheduled api is for getting info whether there is notification set or not. But it is not working.


#5

Did you solve this issue?
If not - are you using typescript or javascript?


#6

I m using typescript. I tried hard to make such script so that button will be visible when there is no alarm. But failed.


#7

Not sure if that cause your problem but according to the docs you should use this syntax:

import {LocalNotifications} from 'ionic-native';

...

// Schedule
LocalNotifications.schedule({
  id: 1,
  text: "Single Notification",
  sound: 'file://sound.mp3'
  data: { secret: key }
});

// Check
LocalNotifications.isScheduled(id).then((isScheduled) => {
  alert("Scheduled: " + isScheduled);
});