In my app, I have list of friends say: 3 friends, all these three have birthday details. I need to schedule local notification to show their b’days alert. I know and handled a local notification but how will I handle these multiple notification?
I am setting fire date in "for loop”.Is it proper, See the code.
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
NSDateFormatter *formatter = [[[NSDateFormatter alloc]init]autorelease];
for (int i = 0; i< [delegate.viewController.contactList count] ; i++) {
NSString *birthday = [[myArray objectAtIndex:i]objectForKey:@"birthday"];
[formatter setDateFormat:@"MM/dd/yyyy"];
NSDate *date = [formatter dateFromString:birthday];
localNotif.fireDate = [date dateByAddingTimeInterval:10];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
NSLog(@"local %@",localNotif.fireDate);
}
localNotif.applicationIconBadgeNumber = 1;
NSString *itemName = @“Friend Name";
NSDictionary *userDict = [NSDictionary dictionaryWithObjectAndKey:itemName,@"msg", nil];
localNotif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
What I want,in this method only I have to set notification for all the friend based on their date. can any one tell me where I’m doing wrong and if I’m missing anything please inform me.