I am trying to open a specific view controller on click of local notification, if app is in background, i am unable to do that because i don't have [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
in applicationDidBecomeActive
method. Please help if you can, Thanks in advance.
Asked
Active
Viewed 1,273 times
0

Muhammad Umair
- 583
- 11
- 32
-
http://stackoverflow.com/a/15502253/1850983 Check above link. It will help you to solve problem. – Payal Maniyar Apr 08 '16 at 11:24
-
@PayalManiyar Thanks for your answer, I want to do this if app is foreground, the link you mentioned above is fine, if app is not in foreground. How would i know that user clicked on notification, because didFinishLaunchingWithOptions will not called. – Muhammad Umair Apr 08 '16 at 11:27
-
I have given answer. please upvote. – Payal Maniyar Apr 08 '16 at 11:30
-
Thanks please vote up the question too. – Muhammad Umair Apr 08 '16 at 11:34
-
I was not facing the issue so sorry. – Payal Maniyar Apr 08 '16 at 11:35
1 Answers
1
do like
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
yourViewController *obj=[storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerStoryboardID"];
// [self.window.rootViewController.navigationController pushViewController:obj animated:YES];
self.window.rootViewController = obj;
Update
- (void)applicationDidBecomeActive:(UIApplication *)application {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MapViewController *obj=[storyboard instantiateViewControllerWithIdentifier:@"Map"];
// [self.window.rootViewController.navigationController pushViewController:obj animated:YES];
self.window.rootViewController = obj;
}
Update1
you can get the localnotification action in here
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
for complete tutorial see this

Community
- 1
- 1

Anbu.Karthik
- 82,064
- 23
- 174
- 143
-
-
@ Anbu.Karthik how would i know that user clicked on notification or not? – Muhammad Umair Apr 08 '16 at 11:22
-
1@MuhammadUmair - check the updated answer at the same time see this tutorial also it will solve ur issue https://nrj.io/simple-interactive-notifications-in-ios-8/ – Anbu.Karthik Apr 08 '16 at 11:28