Apple push notifications 从NotificationContent Extension-iOS导航到特定的视图控制器

Apple push notifications 从NotificationContent Extension-iOS导航到特定的视图控制器,apple-push-notifications,unnotificationscontentextension,Apple Push Notifications,Unnotificationscontentextension,我已经使用通知内容扩展实现了推送通知的自定义UI。我添加了一个“查看”操作,如下所示 let navigateAction = UNNotificationAction(identifier: "ActionNotification", title: "View", options: []) let deafultCategory = UNNotificationCategory(identifier: "myNotifService", actions: [navigateAct

我已经使用通知内容扩展实现了推送通知的自定义UI。我添加了一个“查看”操作,如下所示

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

let deafultCategory = UNNotificationCategory(identifier:
    "myNotifService", actions: [navigateAction], intentIdentifiers:[], options: [])
现在,在内容扩展的类-NotificationViewController中

func didReceive(_ response: UNNotificationResponse, completionHandler completion:(UNNotificationContentExtensionResponseOption) -> Void) {
   if response.actionIdentifier == "ActionNotification" {
       // HERE I NEED TO NAVIGATE TO SPECIFIC VIEW CONTROLLER
   }
   completion(.dismiss)
}
每当我点击“查看”按钮,上面的功能就会被触发,但我需要从这里导航到特定的屏幕。请帮忙

提前感谢。

请快速尝试

let viewController = MyViewController(nibName: "MyNextViewController", bundle: nil)
self.navigationController?.pushViewController(viewController, animated: true)
或用于正常转换

    next:MyViewController = storyboard?.instantiateViewControllerWithIdentifier("MyViewViewController") as!  MyViewViewController  
    self.navigationController?.pushViewController(next, animated: true)
对于objective-c尝试


您正在使用故事板吗?是的@Odwori,我正在使用故事板。as!MyViewController-当我用my view Controller“使用未声明的类型”ABCController替换时,此处显示错误。我猜这不是从ContentExtension导航的方式。感谢您的回复@Odwori。