0

how can i show specific viewcontroler in notification action? in appdelegate

func usernotificationcenter(_center: UNUserNotification,didReceive response: UNNotificationPesponse,withCompletionHalndler completion Handler: @escaping () -> Void){ 

   if identifer == "SHOWVIEW_ACTION":
                //I want show specific viewController at this

   }
  • 3
    Possible duplicate of [Dismiss and Present View Controller in Swift](https://stackoverflow.com/questions/37771001/dismiss-and-present-view-controller-in-swift) –  Aug 29 '17 at 03:13

2 Answers2

0

Add these Lines of code in did receive response, it worked for me

 let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let navigationController = self.window?.rootViewController as? UINavigationController
    let destinationController = storyboard.instantiateViewController(withIdentifier: "YourIdentifierName") as? YourViewController
    navigationController?.pushViewController(destinationController!, animated: false)
var presentedVC = self.window?.rootViewController
        while (presentedVC!.presentedViewController != nil)  {
            presentedVC = presentedVC!.presentedViewController
        }
0
func redirectToSpecificVC() {
let mainStoryboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController: UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "versesVC") as UIViewController
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()}

used these function redirect to specific view controller

Mayank
  • 315
  • 2
  • 13