Powtarzaj UILocalNotification codziennie o 17:00
Jak powtarzać UILocalNotification codziennie o 17:00? Poniżej znajduje się mój kod do ustawiania czasu niestandardowego. Chcę jednak powiadamiać użytkownika codziennie o niestandardowym lub statycznym czasie. Używam iOS 6.
-(void)scheduleNotification{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:timeStr];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = dateFromString;
localNotif.repeatInterval = kCFCalendarUnitDay;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
// Notification details
localNotif.alertBody = @"Reminder is set";
// Set the action button
localNotif.alertAction = @"Ok";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Local Push received while running", @"key", nil];
localNotif.userInfo = infoDict;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}