1 - (IBAction)schedule {
2 // 1.创建本地推送通知对象
3 UILocalNotification *ln = [[UILocalNotification alloc] init];
4
5 // 2.设置通知属性
6 // 音效文件名
7 ln.soundName = @"buyao.wav";
8
9 // 通知的具体内容
10 ln.alertBody = @"重大新闻:xxxx xxxx被调查了....";
11
12 // 锁屏界面显示的小标题("滑动来" + alertAction)
13 ln.alertAction = @"查看新闻吧";
14
15 // 通知第一次发出的时间(5秒后发出)
16 ln.fireDate = [NSDate dateWithTimeIntervalSinceNow:5];
17 // 设置时区(跟随手机的时区)
18 ln.timeZone = [NSTimeZone defaultTimeZone];
19
20 // 设置app图标数字
21 ln.applicationIconBadgeNumber = 5;
22
23 // 设置通知的额外信息
24 ln.userInfo = @{
25 @"icon" : @"test.png",
26 @"title" : @"重大新闻",
27 @"time" : @"2014-08-14 11:19",
28 @"body" : @"重大新闻:答复后即可更换就肯定会尽快赶快回家的疯狂估计很快将发的"
29 };
30
31 // 设置启动图片
32 ln.alertLaunchImage = @"Default";
33
34 // 设置重复发出通知的时间间隔
35 // ln.repeatInterval = NSCalendarUnitMinute;
36
37 // 3.调度通知(启动任务)
38 [[UIApplication sharedApplication] scheduleLocalNotification:ln];
39 }
40
41 - (IBAction)cancel {
42 NSArray *notes = [UIApplication sharedApplication].scheduledLocalNotifications;
43 NSLog(@"%@", notes);
44 // [[UIApplication sharedApplication] cancelAllLocalNotifications];
45 }