Printing description of localNotification:
{fire date = Wednesday, August 5, 2015 at 9:00:00 AM India Standard Time, time zone = (null), repeat interval = NSCalendarUnitDay, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Thursday, August 6, 2015 at 9:00:00 AM India Standard Time, user info = (null)}
As you see the Time is 9:00:00 AM morning but it never fires here what i am doing
- I am testing on Simulator by changing my Mac Time , is that the case ?
- i have also tired to change the my mac time to next fire date , Still not working .
- will these work perfectly in Live device ?
Update Code
var calendar = NSCalendar.currentCalendar()
// calendar.timeZone = NSTimeZone(forSecondsFromGMT: 0)
let comp = NSDateComponents()
//comp.timeZone = NSTimeZone(forSecondsFromGMT: 0)
comp.day = NSDate().day()
comp.month = NSDate().month()
comp.year = NSDate().year()
comp.hour = date.hour()
comp.minute = date.minute()
var grouptimestamp = calendar.dateFromComponents(comp)?.getCurrentTimeStemp()
var minutes = self.getMinutestFromTimestemp(NSDate.getCurrentTimeStemp() - grouptimestamp!)
if minutes > 59 {
println("Missed")
}else if minutes < -5 {
println("Early")
}else{
println("Takenow")
}
UIApplication.sharedApplication().cancelAllLocalNotifications()
var localNotification:UILocalNotification = UILocalNotification()
localNotification.alertAction = "Myplan"
localNotification.alertBody = "Woww it works!!"
localNotification.fireDate = NSDate(timeIntervalSince1970: NSTimeInterval(grouptimestamp!))
localNotification.repeatInterval = NSCalendarUnit.CalendarUnitDay
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)