Question

I have a Local Notifications. Like this ;

NSNumberFormatter *faturaSonOdemeGunuFormatter = [[NSNumberFormatter alloc] init];
[faturaSonOdemeGunuFormatter setNumberStyle:NSNumberFormatterNoStyle];
NSNumber *faturaSonOdemeGunuNumber = [faturaSonOdemeGunuFormatter numberFromString:_txtFaturaGunu.text];

NSDate *currentDate = [NSDate date];
NSCalendar * calendar = [NSCalendar currentCalendar];
[calendar setTimeZone:[NSTimeZone systemTimeZone]];
NSDateComponents* components = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit fromDate:currentDate];

[components setTimeZone:[NSTimeZone systemTimeZone]];
[components setHour:12];
[components setMinute:40];
[components setDay: faturaSonOdemeGunuNumber.integerValue -3];

NSDate *test = [calendar dateFromComponents:components];


// Schedule the notification
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = test;
localNotification.alertBody = [NSString stringWithFormat:@"%@ Faturanıza 3 gün kaldı.",_txtFaturaAdi.text];
localNotification.alertAction = @"Faturayı göster";
localNotification.timeZone = [NSTimeZone systemTimeZone];
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

// Request to reload table view data
[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadData" object:self];

This code does not repeat itself.I want to repeat Local Notification every Month in faturaSonOdemeGunuNumber integerValue day.It should be start sonOdemeGunuNumber -3 (for example user writes 17. it should start 14) and it should give a notification on every day until faturaSonOdemeGunuNumber. I mean it should continue notify the users every day until selected day. How can i do that?

Thank you!

Was it helpful?

Solution

Add this:

localNotification.repeatInterval = kCFCalendarUnitMonth; //For monthly repeats
localNotification.repeatInterval = kCFCalendarUnitDay; //For daily repeats 

OTHER TIPS

Try this,

notification.repeatInterval= NSDayCalendarUnit;    //For day
notification.repeatInterval= NSWeekCalendarUnit;   //For Week 
notification.repeatInterval= NSMonthCalendarUnit;  //For Month

Ref Link: http://useyourloaf.com/blog/2010/09/13/repeating-an-ios-local-notification.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top