Search code examples
iosobjective-cuilocalnotificationnscalendar

UILocalNotification with repeatInterval set NSWeekdayCalendarUnit doesn't trigger weekly


I'm trying to setup local notification to repeat weekly.
Here's my setup:

UILocalNotification* localNotification =  [[UILocalNotification alloc] init];
...
localNotification.repeatInterval = NSWeekdayCalendarUnit;

In console log:

localNotif: {fire date = Friday, April 24, 2015 at 12:27:33 PM Singapore Standard Time, time zone = Asia/Singapore (GMT+8) offset 28800, repeat interval = NSWeekdayCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Saturday, April 25, 2015 at 12:27:33 PM Singapore Standard Time, user info = { KUserLocalNotficationKey = "2015-04-24 04:27:33 +0000"; }}

As you can see, the next fire date is trigger on the next day. Is this a bug?
I've tested it in iOS 7.1, 8.1, 8.3.


Solution

  • PLz Try this

      UILocalNotification *localNotif=[[UILocalNotification alloc]init];
            localNotif.fireDate =currentDate;
            localNotif.timeZone=[NSTimeZone defaultTimeZone];
            localNotif.alertBody = @"MazeRoll";
            localNotif.soundName = UILocalNotificationDefaultSoundName;
            localNotif.applicationIconBadgeNumber = 1;
            localNotif.repeatInterval=NSWeekCalendarUnit;
            UIApplication *app=[UIApplication sharedApplication];
            [app scheduleLocalNotification:localNotif];
            NSLog(@"sdfsdfsdf%@",[[UIApplication sharedApplication] scheduledLocalNotifications]);