Reputation: 11782
I am using following code
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = fireDate;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = @"Have you seen your Chiropractic this Month?";
localNotification.alertAction = @"Continue";
localNotification.repeatInterval = NSMonthCalendarUnit;
localNotification.applicationIconBadgeNumber = 0;
// Schedule it with the app
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release];
How can i set "fireDate" so that this notification runs only on lets say 5th of every month. Secondly this code is in appDelegate.h. How will i set it so that it launches only one notification each month
Upvotes: 0
Views: 268
Reputation: 38728
I'm going to guess that the question is actually how do I create a date object to start from
You could start with something like this
NSCalendar *calender = [NSCalendar currentCalendar];
calender.timeZone = [NSTimeZone timeZoneWithName:@"GMT"];
NSDateComponents *components = [calender components:NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]];
components.day = 5;
components.hour = 12;
components.minute = 30;
NSDate *fireDate = [calender dateFromComponents:components];
Upvotes: 1