Make sure you see Registering for local notifications in order for this to work:
let notification = UILocalNotification() notification.alertBody = "Hello, local notifications!" notification.fireDate = NSDate().dateByAddingTimeInterval(10) // 10 seconds after now UIApplication.sharedApplication().scheduleLocalNotification(notification)
UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.alertBody = @"Hello, local notifications!"; notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10]; // 10 seconds after now [[UIApplication sharedApplication] scheduleLocalNotification:notification];
To see the notification in the iOS Simulator, type
^⌘H (control-command-H) to go home and then type
⌘L (command-L) to lock the device. Wait a few seconds, and the notification should appear (this appearance will vary depending on notification type discussed in "Registering for local notifications"):
Swipe on the notification to get back to the app (note that if you called this in the first view controller's
viewDidAppear, etc., the notification will be scheduled again).