I want to navigate to a specific viewcontroller when the I click on a push notification.
I have written this code in my didReceiveRemoteNotification method.
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "deals") as! FYIDealsVC
let naviVC:UINavigationController? = self.window?.rootViewController?.revealViewController().frontViewController as? UINavigationController
naviVC?.pushViewController(vc, animated: true)
}
But it's giving me this error which crashes the app.
fatal error: unexpectedly found nil while unwrapping an Optional value
There are many posts with navigation controller or just presenting the viewcontroller. But I want to navigate to the specific view with reveal.
Any help would be highly appreciated.