【问题标题】:Navigate to specific view controller from NotificationContent Extension - iOS从通知内容扩展导航到特定视图控制器 - iOS
【发布时间】:2019-09-18 06:41:45
【问题描述】:

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

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

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

现在,在 Content Extension 的类 - NotificationViewController

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

每当我单击“查看”按钮时,都会触发上述功能,但我需要从此处导航到特定屏幕。请帮忙。

提前致谢。

【问题讨论】:

  • 你在使用故事板吗?
  • 是的@Odwori,我正在使用情节提要。

标签: apple-push-notifications unnotificationscontentextension


【解决方案1】:

快速尝试

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试试

Try this answer

【讨论】:

  • 作为! MyViewViewController - 当我用我的视图控制器替换时显示错误“使用未声明的类型”ABCController”。我想这不是从 ContentExtension 导航的方式。感谢您的回复@Odwori。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-06-11
  • 2015-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-08
  • 1970-01-01
相关资源
最近更新 更多