一、添加状态栏、桌面、锁屏通知:
/*
添加状态栏、桌面、锁屏通知
*/
- (void)addLocalNotification{
//1.创建通知
UILocalNotification *n = [[UILocalNotification alloc] init];
//2.设置在哪里通知
n.alertAction = @"通知标题";
n.alertBody = @"通知内容";
//设置桌面APP图标标未读数
n.applicationIconBadgeNumber = 5;
//重复间隔
n.repeatInterval = NSCalendarUnitMinute;
//状态栏通知图标
n.alertLaunchImage = @"img";
n.fireDate = [NSDate dateWithTimeIntervalSinceNow:3];
//3.注册
UIApplication *app = [UIApplication sharedApplication];
[app scheduleLocalNotification:n];
}
二、取消通知:
/*
取消通知
*/
- (void)cancelLocalNotification{
UIApplication *app = [UIApplication sharedApplication];
[app cancelAllLocalNotifications];
}