I want to implement uilocalnotification
in my app. but the problem is that it is not firing at the exact time. it is firing after 30 - 40 secs from the given fi
You can set fireDate
by using NSDateComponents
, in which you can set seconds for firedate. When I set it to 0 doesn't work, but it works if I set it to 1 seconds. 1 second late will be OK compared to 30-40 seconds.
NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents *dateComps = [cal components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay |NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond fromDate:fireDate];
[dateComps setSecond:1];
[dateComps setNanosecond:00];
NSDate *newDate = [cal dateFromComponents:dateComps];
fireDate = newDate;