IOS设置本地通知

来源:互联网 发布:数据上限下限设定 编辑:程序博客网 时间:2024/06/06 23:47
/*******  设置本地通知  ********/-(void)PlatformSetLocalNotification:(int)minutes hour:(int)hour day:(int)day month:(int)month year:(int)year noticeStr:(NSString*)noticeStr{    //首先清空    [[UIApplication sharedApplication] cancelAllLocalNotifications];    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];        //添加通知    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];    NSDateComponents *dateComps = [[NSDateComponents alloc] init];    [dateComps setDay:day];    [dateComps setMonth:month];    [dateComps setYear:year];    [dateComps setHour:hour];    [dateComps setMinute:minutes];    NSDate *itemDate = [calendar dateFromComponents:dateComps];    [dateComps release];        UILocalNotification *notification=[[UILocalNotification alloc] init];        notification.fireDate = itemDate;    notification.timeZone=[NSTimeZone defaultTimeZone];        NSString *str_m = nil;    str_m = noticeStr;    notification.alertBody = str_m;    notification.alertAction =@"View";    [[UIApplication sharedApplication] scheduleLocalNotification:notification];    [notification release];    NSLog(@"PlatformSetLocalNotification end");}

0 0
原创粉丝点击