Trying to get a tableview class set up to display local notifications that the user can set within the application.
The view controller that sets the notification:
viewDidLoad of the tableview class:
But, the log always returns 0. Any thoughts?
The view controller that sets the notification:
Code:
- (void)scheduleNotification {
[reminderText resignFirstResponder];
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil) {
UILocalNotification *notif = [[cls alloc] init];
notif.fireDate = [datePicker date];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = reminderText.text;
notif.alertAction = @"Ok";
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;
NSInteger index = [scheduleControl selectedSegmentIndex];
switch (index) {
case 1:
notif.repeatInterval = NSDayCalendarUnit;
break;
case 2:
notif.repeatInterval = NSWeekCalendarUnit;
break;
default:
notif.repeatInterval = 0;
break;
}
NSDictionary *userDict = [NSDictionary dictionaryWithObject:reminderText.text
forKey:kRemindMeNotificationDataKey];
notif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];
}
}
Code:
NSMutableArray * notifications = [[[UIApplication sharedApplication] scheduledLocalNotifications]mutableCopy];
NSLog(@"%i", notifications.count);