UILocalNotification *notification=[[UILocalNotificationalloc] init];
if (notification!=nil) {
NSLog(@">> support local notification");
NSDate *now=[NSDatenew];
notification.fireDate=[now addTimeInterval:10];
notification.timeZone=[NSTimeZonedefaultTimeZone];
notification.alertBody=@"信息";
[notification setApplicationIconBadgeNumber:10];
[notification setSoundName:@"ping.caf"];
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
读取所有scheduledLocalNotifications
for(UILocalNotification *aNotif in [[UIApplication sharedApplication] scheduledLocalNotifications]) {
NSLog(@"%@",aNotif.timeZone);
NSLog(@"%@",aNotif.alertBody);
}
NSLog(@"count=%d", [[[UIApplication sharedApplication] scheduledLocalNotifications] count] );
本文介绍如何在iOS应用中使用Objective-C设置本地通知,包括指定触发时间、设置提醒内容及图标角标数字等,并展示了如何读取已安排的所有本地通知。
143

被折叠的 条评论
为什么被折叠?



