UILocalNotification每分钟重复

我想每隔一分钟发送本地通知,写出的代码:

[[UIApplication sharedApplication] cancelAllLocalNotifications];

    UILocalNotification *notif = [[UILocalNotification alloc] init];

    if (notif == nil) {
        return;
    }

    notif.timeZone = [NSTimeZone defaultTimeZone];

    notif.alertBody = @"Test notification!";
    notif.alertAction = @"View";
    notif.soundName = UILocalNotificationDefaultSoundName;
    notif.applicationIconBadgeNumber += 1;

    notif.repeatInterval = NSMinuteCalendarUnit;

    [[UIApplication sharedApplication] scheduleLocalNotification:notif];

但是它只发送一次就不再发送了。不知道怎么改。请大家帮忙解决。

你要给通知设置一个firedate,不然应用就会这样,通知立即发送,然后不重复。

firedate根据制定的时间值执行,如果指定的时间值是空,或者已经过期了,那么通知就会立即发送