Reputation: 287
I have an actionable notification setup on my app with a YES button. Is it possible, when the notification is triggered and you press the Yes button, to take you into the app on a specific view controller, not the initial view.
Upvotes: 0
Views: 790
Reputation: 31091
Yes you can use new method handleActionWithIdentifier
of iOS8 to this task. Whenever you press action button , these delegate will call.
Delegate for localNotification : Called when your app has been activated by the user selecting an action from a local notification.
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler
Delegate for remoteNotification : Called when your app has been activated by the user selecting an action from a remote notification.
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
Note : You should call the completion handler as soon as you've finished handling the action.
Then you can get your rootViewController
using this and then redirect to other ViewController.
- (UIViewController*)GetTopViewController
{
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
UIViewController *rootViewController = appDelegate.window.rootViewController;
if ([rootViewController isKindOfClass:[UINavigationController class]])
{
UINavigationController* rvc = (UINavigationController*)rootViewController;
rootViewController = rvc.visibleViewController;
}
return rootViewController;
}
Other related Question Link
Upvotes: 0