0

I am working in sencha touch and now I want to use the local notification in my project so I used this plugin for the local notification.

https://github.com/katzer/cordova-plugin-local-notifications

the problem that I face is just that I can't display my notification on a specific time and date. It shows immediately the notification as i clicked on the action button so please help me out from this problem.

  • Can you provide a use case ? Why do you need to delay the apparition of the notification ? It seems more like a design flaw, notifications are not meant to be delayed, they are used to react to an event. – NitroG42 Apr 24 '14 at 07:51
  • i want to display a notification as a medicine reminder which the user insert time at that time n date i would like to display my notification alert i don't think so any design flaw is here – user2751590 Apr 24 '14 at 09:50
  • It's not a design flaw, but what you want is an event that fire the notification at the right time, not the notification that display by itself at your time. – NitroG42 Apr 24 '14 at 09:56
  • What I mean is you need something called Alarms in Android : http://developer.android.com/training/scheduling/alarms.html Unfortunately it seems there are no equivalents in Sencha. – NitroG42 Apr 24 '14 at 09:59
  • yess i want the notification that display by itself at user input time have you see this plugin – user2751590 Apr 24 '14 at 10:42
  • You will be better off using push notifications: https://github.com/phonegap-build/PushPlugin – Jeff Wooden Apr 24 '14 at 15:50
  • For a medicine reminder ? It's local, and what about if there are no internet connection ? I'm sorry but i don't think it's a good idea, and anyway there is no plugin for delaying a task in sencha/cordova. – NitroG42 Apr 25 '14 at 12:09
  • @JefferyAWooden yes i want just it locally no internet connection is required.. – user2751590 Apr 25 '14 at 17:12
  • you can give the specific time in date object. window.plugin.notification.local.add({date: __ }); – AmmY May 13 '14 at 19:38

1 Answers1

0

The example below should work. I tested it myself. Be aware that if the date is in the past according to your phone the notification will pop up directly after you have set the notification.

var beginTime = new Date('2016', '0', '12', '12', '45'); 
//year 
//month - 1 (month starts at 0 so you have 0-11)
//day
//hour
//minutes

cordova.plugins.notification.local.schedule({
    id: 1,
    title: 'Hello World',
    text: 'My first notification',        
    at: beginTime        
})
Sjoerd Pottuit
  • 2,307
  • 4
  • 20
  • 35