转载自:http://blog.youkuaiyun.com/tangren03/article/details/8914208
- UILocalNotification *notification = [[UILocalNotification alloc] init];
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"HH:mm:ss"];
- //触发通知的时间
- NSDate *now = [formatter dateFromString:@"15:00:00"];
- notification.fireDate = now;
- //时区
- notification.timeZone = [NSTimeZone defaultTimeZone];
- //通知重复提示的单位,可以是天、周、月
- notification.repeatInterval = NSDayCalendarUnit;
- //通知内容
- notification.alertBody = @"这是一个新的通知";
- //通知被触发时播放的声音
- notification.soundName = UILocalNotificationDefaultSoundName;
- //执行通知注册
- [[UIApplication sharedApplication] scheduleLocalNotification:notification];