[英]Launch app on specific view controller using iOS8 actionable notifications
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. 触发通知并按“是”按钮时,是否可以将您带入特定视图控制器(而不是初始视图)上的应用程序。
Yes you can use new method handleActionWithIdentifier
of iOS8 to this task. 是的,您可以对此任务使用handleActionWithIdentifier
的新方法handleActionWithIdentifier
。 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. 代表localNotification :当用户从本地通知中选择一个操作激活了您的应用后调用。
- (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. 代表remoteNotification :当用户从远程通知中选择一个操作激活了您的应用程序时调用。
- (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. 然后,您可以使用此方法获取rootViewController
,然后重定向到其他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 其他相关问题链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.