I have two table view both has different NSMutableArray
with dictionary at every index.dictionary has a date field in NSString format. Now my problem is when user set time with picker view than every day he got local notification
at the same time if record available for that day.
I have no idea how to implement this please help me..
Thank you

- 314,917
- 42
- 532
- 579

- 33
- 3
-
so you want to implement simple local notification for that specific date string? – Irfan May 23 '14 at 09:44
2 Answers
In your case you need to set fireDate
its is date/time on which your notification will be arrive and also set repeatInterval
it's describe repetition of your notification. Here you need to set kCFCalendarUnitDay
because you want to repeat notification daily.
REPEAT UNIT:
NSEraCalendarUnit
NSYearCalendarUnit
NSMonthCalendarUnit
NSDayCalendarUnit
NSHourCalendarUnit
NSMinuteCalendarUnit
NSSecondCalendarUnit
NSWeekCalendarUnit
NSWeekdayCalendarUnit
NSWeekdayOrdinalCalendarUnit
NSQuarterCalendarUnit
For more information there are some SO's question.
Repeat UILocalNotification daily at 5 pm
iPhone : Daily local notifications
http://useyourloaf.com/blog/2010/09/13/repeating-an-ios-local-notification.html
In AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[launchOptions valueForKey:UIApplicationLaunchOptionsLocalNotificationKey];
return YES;
}
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
UIAlertView *notificationAlert = [[UIAlertView alloc] initWithTitle:@"Notification" message:@"This local notification" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[notificationAlert show];
// NSLog(@"didReceiveLocalNotification");
}
This code in .m file to your ViewController :
-(IBAction)startLocalNotification
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:timeStr];
NSLog(@"startLocalNotification");
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = dateFromString;
notification.repeatInterval = NSDayCalendarUnit;
notification.alertBody = @"This is local notification!";
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 10;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}

- 1,765
- 1
- 18
- 26