Reputation: 1073
My app sends local notifications and in each one there is an ID. Once the user click on one of the notifications It should appear a specific View which should have received notification ID.
Ex. The notification with ID 23 appears, the user click on it and app should show the screen "details" where will be loaded all the informations of the id 23.
So in my AppDelegate I use this method to intercept the user notification click.
- (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
But in this method if I perform a segue it does not work. Instead with the following code It almost works but the "eventDetails" view appear empty becuase I'm not able to pass it the notification ID.
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"eventDetails"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window setRootViewController:navigationController];
//[self.window setBackgroundColor:[UIColor whiteColor]];
[self.window makeKeyAndVisible];
Upvotes: 0
Views: 1151
Reputation: 1073
Solution Found!
I added on top of my appdelegate.m this:
#import "eventDetailsController.h"
And changed the previous code like the following:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
eventDetailsController *edView = [[dettaglioEvento alloc] init];
edView = [mainStoryboard instantiateViewControllerWithIdentifier:@"eventDetails"];
edView.passedId = self.idToShow;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:edView];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window setRootViewController:navigationController];
//[self.window setBackgroundColor:[UIColor whiteColor]];
[self.window makeKeyAndVisible];
Upvotes: 0
Reputation: 787
You can try in this way and I hope it will work for you
- (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
// codes of Local Notification
[self.rootviewcontroller.view addSubView:infoView];
}
Upvotes: 1