Question

I'm trying to build an alarm clock app, and am using the localNotification and trying to adapt the code from http://www.drewdahlman.com/meusLabs/?p=84.

My app is a combination of phonegap with backbone. I'm setting the localNotification with

plugins.localNotification.add({ 
           date: set_alarm, 
           message: 'Wakey Wakey...', 
           badge: 0, 
           id: 12, 
           sound:'Alarm.cab',
           background:'MyApp.Views.Alarm.notification()',
           foreground:'MyApp.Views.Alarm.notification()' 
           });

later, in my MyApp.Views.Alarm i have

notification: function(){
   alert('alarm');
}

unfortunately, this alert is never triggered in iOS simulator.

xCode outputs the following

2012-07-25 10:06:25.054 Wakey[8253:13403] 
  Notification Set: 2012-07-25 10:07:25 +0000 
  (ID: 12, Badge: 0, sound: Alarm_01.cab,
   background: Wakey.Views.Alarm.notification(), 
   foreground: Wakey.Views.Alarm.notification())
2012-07-25 10:06:25.055 Wakey[8253:13403] [INFO] 2012-07-25T10:07:25.044Z
2012-07-25 10:06:25.056 Wakey[8253:13403] [INFO] "2012-07-25T10:07:25.044Z"
2012-07-25 10:06:25.058 Wakey[8253:13403] I was currently active

The strange part is, I can't find anywhere the in my code where I'm outputing 'I was currently active'. Which I find strange, and it isn't in the localNotification plugin files.

Any suggestions as to why my notifications aren't being triggered?

Was it helpful?

Solution

change the formatting on your foreground and background functions.

plugins.localNotification.add({ 
           date: set_alarm, 
           message: 'Wakey Wakey...', 
           badge: 0, 
           id: 12, 
           sound:'Alarm.cab',
           background:'MyApp.Views.Alarm.notification',
           foreground:'MyApp.Views.Alarm.notification' 
           });

On the objective C side of things the functions are called and have the id of the notification included as an argument.

The most recent update of the plugin added the ability to have the id's included in the callback, and documentation needs to be updated.

cheers!

EDIT - I am updating the tutorial, a lot has changed since the original post and I need to consolidate all of the posts!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top