创建本地通知

1、在APPdelegate里面注册本地通知
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert categories:nil]];
//2、创建本地通知
    UILocalNotification *notification = [[UILocalNotification alloc]init];
    //时区
    notification.timeZone = [NSTimeZone defaultTimeZone];
    //开启通知时间
    notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
    //重复间隔
    notification.repeatInterval = kCFCalendarUnitMinute;
    //重复的日历
    notification.repeatCalendar = [NSCalendar currentCalendar];/**<  当前的日历 */
    //通知标题
    notification.alertTitle = @"该吃药了";
    //通知内容
    notification.alertBody = @"尊敬的xx,你要吃xx药了";
    
    notification.applicationIconBadgeNumber = 3;
    
    notification.soundName = UILocalNotificationDefaultSoundName;
    
    //添加
    
    [[UIApplication sharedApplication]scheduleLocalNotification:notification];
    
    //移除
    [[UIApplication sharedApplication] cancelAllLocalNotifications];

通知使用完以后需要移除

你可能感兴趣的:(创建本地通知)