KkMIW
KkMIW

Reputation: 1112

how to set local notification for every two weeks

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

Upvotes: 0

Views: 481

Answers (2)

Ashish Jain
Ashish Jain

Reputation: 91

Set repeatInterval of UILocalNotification to NSCalendarUnitDay.

Upvotes: 0

Ekta Padaliya
Ekta Padaliya

Reputation: 5799

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

Upvotes: 1

Related Questions