推送通知在 TabBarController NavigationController revealViewController 中打开特定屏幕

Push Notification open specific screen in TabBarController NavigationController revealViewController

这就是我想要做的。 当我收到推送通知并点击我想在我的应用程序中显示特定屏幕时。我发现了很多关于它的信息,但由于应用程序结构的复杂性,我遇到了麻烦。 以下是应用程序的结构:

我想将一些参数传递给 DetailViewContorller 以便我可以确保在打开屏幕时得到正确的结果。 这是我的应用程序结构的屏幕截图 application Folow

在我的 AppDelegate 中使用以下代码:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tb = storyboard.instantiateViewControllerWithIdentifier("TabBarVC") as! UITabBarController 
tb.selectedIndex = 1
window?.rootViewController? = tb

我在点击通知时成功进入了标签栏,但我对结果不满意。我仍然遇到以下问题:

  1. revealViewController 为零,所以我无法打开我的设置面板
  2. 我仍然没有到达视图层次结构底部的 DetailViewController

如有任何提示,我们将不胜感激。

我遇到了类似的问题,尽管我的流程有点不同。我最终处理了推送通知事件(当用户点击它时)并将对象存储在应用程序委托级别。在之后出现的每个视图控制器中(在 ViewDidLoad() 方法中),我将检查该对象并确定是否将流重定向到下一个视图控制器。为了解决这个问题,我的通知有一个与之关联的类型。不幸的是,我找不到更好的解决方案。

P.S。看起来您正在代码中实例化视图控制器,而我正在使用故事板。但是,基本思想是相同的。我结束了

@MK_Dev,感谢您的建议,但我一直在寻找更容易管理的东西。

这实际上帮助了我。 Get top most UIViewController

这是我所做的:

if var topControl = UIApplication.sharedApplication().keyWindow?.rootViewController {
            while let presentedContreller = topControl.presentedViewController{
                topControl = presentedContreller
            }
            if topControl.childViewControllers[0].isKindOfClass(MyCustomClassVC) {
            // Check if the user is already on the VC we are trying to open
                let chatController = topControl.childViewControllers[0] as! MyCustomClassVC 
// ... any additional code you need to add here ...
    }
}