- (void) setupLocalNotification:(NSString*)dateString {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"EEST"]];
[formatter setDateFormat:@"yyyy-MM-dd HH mm"];
NSDate *itemDate = [formatter dateFromString: dateString];
if ([itemDate compare:[NSDate dateWithTimeIntervalSinceNow:0.1]] == NSOrderedAscending) {
return;
}
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = itemDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = @"Alert message";
// Set the action button
localNotif.alertAction = @"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
No comments:
Post a Comment