when user taps push notification, want them taken specific table view controller in app. table view controller embedded in navigation controller, embedded in tab bar controller (my root view controller). image shown below visualizes this.
the root view tab bar controller has storyboard id of "homevc" , class name of "homeviewcontroller", navigation controller has storyboard id of "settingsnavigationvc", , table view controller has storyboard id of "settingstablevc" , class name of "settingsnavigationvc".
i have push notifications working. working, mean can send message device , receive on device, when receiver taps notification can't seem other view controller open other root view controller. according push notification guide i'm using, i'm using following code in didreceiveremotenotification
method:
func application(application: uiapplication, didreceiveremotenotification userinfo: [nsobject: anyobject]) { let rootvc = self.window!.rootviewcontroller if pfuser.currentuser() != nil { let settingstablevc = settingstableviewcontroller() rootvc?.navigationcontroller?.pushviewcontroller(settingstablevc, animated: false) } }
what doing wrong, or must present right view controller?
try this
let storyboard = uistoryboard(name: "yourstoryboardname", bundle: nil) let rootvc = storyboard.instantiateviewcontrollerwithidentifier("homevc") as! uitabbarcontroller if pfuser.currentuser() != nil { rootvc.selectedindex = 2 // index of tab bar item want present, shown in question seems item 2 self.window!.rootviewcontroller = rootvc }