0

How to trigger local notification for every two weeks?

What i did was:

UILocalNotification *localNotification = UILocalNotification.new;
localNotification.repeatInterval = 14;
localNotification.fireDate = [NSDate dateWithTimeInterval:10 sinceDate:notificationDate];
localNotification.alertBody = notificationMessage;
localNotification.alertAction = @"Open";
localNotification.category = @"default_category";
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
KkMIW
  • 1,092
  • 1
  • 17
  • 27

2 Answers2

1

Try below code:

UILocalNotification *notification = [[UILocalNotification alloc]init];
notification.userInfo = @{@"notification_identifier":@"After14Days"};
notification.fireDate = [[NSDate date] dateByAddingTimeInterval:(60*60*24*14)];
notification.alertBody = @"Text to display";
notification.repeatInterval = NSCalendarUnitDay;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
Ekta Padaliya
  • 5,743
  • 3
  • 39
  • 51
0

Set repeatInterval of UILocalNotification to NSCalendarUnitDay.