Navigate to specific view controller from NotificationContent Extension - iOS

187 Views Asked by At

I have implemented custom UI for push notification using Notification Content Extension. I have added an "View" action as below

let navigateAction = UNNotificationAction(identifier: "ActionNotification", title: "View", options: [])  

let deafultCategory = UNNotificationCategory(identifier:
    "myNotifService", actions: [navigateAction], intentIdentifiers:[], options: [])

Now, in Content Extension's class - NotificationViewController

func didReceive(_ response: UNNotificationResponse, completionHandler completion:(UNNotificationContentExtensionResponseOption) -> Void) {
   if response.actionIdentifier == "ActionNotification" {
       // HERE I NEED TO NAVIGATE TO SPECIFIC VIEW CONTROLLER
   }
   completion(.dismiss)
}

Whenever I click on "View" button, above function is triggered but I need to navigate to specific screen from here. Please help.

Thanks in Advance.

1

There are 1 best solutions below

1
On

for swift try

let viewController = MyViewController(nibName: "MyNextViewController", bundle: nil)
self.navigationController?.pushViewController(viewController, animated: true)

or for normal transition

    next:MyViewController = storyboard?.instantiateViewControllerWithIdentifier("MyViewViewController") as!  MyViewViewController  
    self.navigationController?.pushViewController(next, animated: true)

for objective-c try

Try this answer