我希望每天 7:00 发出通知,但它不会发出。我也希望它显示在锁定屏幕中。这是我到目前为止的所有代码。
-(void)EveryDayNotify
{
NSLog(@"Good Morning Working");
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setAlertBody:@"Good Morning! Have a great day!"];
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
localNotification.repeatInterval = NSDayCalendarUnit;
NSCalendar *calendar = [NSCalendar currentCalendar]; // gets default calendar
NSDateComponents *components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:[NSDate date]]; // gets the year, month, day,hour and minutesfor today's date
[components setHour:07];
[components setMinute:0];
localNotification.fireDate = [calendar dateFromComponents:components];
[localNotification release];
}