[英]Launch app on specific view controller using iOS8 actionable notifications
我的应用程序上有一个可执行的通知设置,带有“是”按钮。 触发通知并按“是”按钮时,是否可以将您带入特定视图控制器(而不是初始视图)上的应用程序。
是的,您可以对此任务使用handleActionWithIdentifier
的新方法handleActionWithIdentifier
。 每当您按下操作按钮时,这些代表就会呼叫。
代表localNotification :当用户从本地通知中选择一个操作激活了您的应用后调用。
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler
代表remoteNotification :当用户从远程通知中选择一个操作激活了您的应用程序时调用。
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
注意:完成操作后,应立即调用完成处理程序。
然后,您可以使用此方法获取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;
}
其他相关问题链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.