0

I want to send local notification every minute and this is code that I'm using:

[[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];

The notification starts only once and never is repeated. Where I make mistakte?

nyanev
  • 11,299
  • 6
  • 47
  • 76
  • visit this one mate:-http://stackoverflow.com/questions/4363847/how-to-set-local-notification-repeat-interval-to-custom-time-interval – Nitin Gohel Nov 21 '12 at 09:57

1 Answers1

2

You have to set a fireDate for your notification, otherwise it won't repeat but fire instantly.

The fire date is interpreted according to the value specified for timeZone. If the specified value is nil or is a date in the past, the notification is delivered immediately.

jimpic
  • 5,360
  • 2
  • 28
  • 37
  • ohh ok then give your Best and Cleaver answer ok i just deleted mine answer be happy :) – Nitin Gohel Nov 21 '12 at 10:19
  • Thanks this help me. After I add `fireDate` notification works – nyanev Nov 21 '12 at 10:20
  • @NitinGohel I didn't mean to offend you, but Stackoverflow is not a full quote community. Take some time to understand the question and give a real answer, don't just copy over some unrelated answer. – jimpic Nov 21 '12 at 10:45