I am having a lot of issues handling my incoming local notifications. My app is using storyboards and has a tabbarcontroller as the rootviewcontroller. Currently I launch the modalviews from 'didReceiveLocalNotification' in the following manner:
MedicationReminderViewController *vc = [[MedicationReminderViewController alloc] initWithNibName:@"MedicationReminderViewController" bundle:nil];
vc.notificationInfo = [[NSDictionary alloc] initWithDictionary:notification.userInfo];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:vc];
navController.navigationBar.barStyle = UIBarStyleBlackOpaque;
navController.title = @"title";
UITabBarController *tc = (UITabBarController *)self.window.rootViewController;
UINavigationController *nc = (UINavigationController *)tc.selectedViewController;
[[nc visibleViewController] presentModalViewController:navController animated:YES];
This works but not on all occasions. I'd like to present the modal view in a new window over anything else that could be displayed at that time. When the user handles the incoming notification the modal view will dismiss itself and the underlying view that was active before the notification came in will be visible again. How can I achieve this?