NSString *yourXMLDate = @"08:00" ;
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"HH:mm"];
NSDate *inputDate = [inputFormatter dateFromString:yourXMLDate];
//创建一个本地推送
UILocalNotification *noti = [[[UILocalNotification alloc] init] autorelease];
if (noti) {
//设置推送时间
noti.fireDate = inputDate;
//设置时区
noti.timeZone = [NSTimeZone defaultTimeZone];
//设置重复间隔
noti.repeatInterval = NSWeekdayCalendarUnit;
//推送声音
noti.soundName = UILocalNotificationDefaultSoundName;
//内容
noti.alertBody = @"推送内容";
//显示在icon上的红色圈中的数子
noti.applicationIconBadgeNumber = 1;
//设置userinfo 方便在之后需要撤销的时候使用
NSDictionary *infoDic = [NSDictionary dictionaryWithObject:@"name" forKey:@"key"];
noti.userInfo = infoDic;
//添加推送到uiapplication
UIApplication *app = [UIApplication sharedApplication];
[app scheduleLocalNotification:noti];
}
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"HH:mm"];
NSDate *inputDate = [inputFormatter dateFromString:yourXMLDate];
//创建一个本地推送
UILocalNotification *noti = [[[UILocalNotification alloc] init] autorelease];
if (noti) {
//设置推送时间
noti.fireDate = inputDate;
//设置时区
noti.timeZone = [NSTimeZone defaultTimeZone];
//设置重复间隔
noti.repeatInterval = NSWeekdayCalendarUnit;
//推送声音
noti.soundName = UILocalNotificationDefaultSoundName;
//内容
noti.alertBody = @"推送内容";
//显示在icon上的红色圈中的数子
noti.applicationIconBadgeNumber = 1;
//设置userinfo 方便在之后需要撤销的时候使用
NSDictionary *infoDic = [NSDictionary dictionaryWithObject:@"name" forKey:@"key"];
noti.userInfo = infoDic;
//添加推送到uiapplication
UIApplication *app = [UIApplication sharedApplication];
[app scheduleLocalNotification:noti];
}