您的位置:首页 > 移动开发 > IOS开发

iOS开发之系统后台运行弹出本地通知

2013-12-20 10:38 417 查看
后台指定时间弹出通知信息:
执行以下代码就可以在每天的指定时间弹出消息,就算是程序被结束之后,同样可以弹出。
UILocalNotification*UILocalNotification alloc] init];

if (nil != notification)
{
//
设置弹出通知的时间
NSDateFormatter *[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH:mm"];
NSDate *nowDate = [dateFormatter dateFromString:@"09:54"];

//设置通知弹出的时间
notification.fireDate = nowDate;
//设置重复重复间隔为每天
notification.repeatInterval = kCFCalendarUnitDay;
//
设置时区
notification.timeZone= [NSTimeZone defaultTimeZone];
//设置提示消息
notification.alertBody = [NSString stringWithFormat:@"%@",@"通知来了"];
//
设置启动通知的声音
notification.soundName = UILocalNotificationDefaultSoundName;
//
启动通知
[[UIApplication sharedApplication]scheduleLocalNotification:notification];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: