Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 在didReceive响应中执行Segue:UNNotificationResponse_Swift_Push Notification - Fatal编程技术网

Swift 在didReceive响应中执行Segue:UNNotificationResponse

Swift 在didReceive响应中执行Segue:UNNotificationResponse,swift,push-notification,Swift,Push Notification,我是Swift的新手,我正在尝试将其与firebase推送通知集成。 推送通知本身工作正常,但我在触摸通知时很难打开特定视图 首先,我尝试用instantaiteViewController方法初始化根视图控制器,但没有成功 因此,我第二次尝试,当用户点击通知时,是否可以从初始视图控制器执行segue 第二个解决方案是我目前想要实现的。 并从UNUserNotificationCenterDelegate的“didReceive响应:UNNotificationResponse”调用perfor

我是Swift的新手,我正在尝试将其与firebase推送通知集成。 推送通知本身工作正常,但我在触摸通知时很难打开特定视图

首先,我尝试用instantaiteViewController方法初始化根视图控制器,但没有成功 因此,我第二次尝试,当用户点击通知时,是否可以从初始视图控制器执行segue

第二个解决方案是我目前想要实现的。 并从UNUserNotificationCenterDelegate的“didReceive响应:UNNotificationResponse”调用perform segue方法

它似乎在表演这一段。通过在目标ViewController的
ViewDidLoad()
ViewWillApear
中打印字符串进行检查

只是它没有显示它的屏幕。 即使在启动目标视图控制器ViewDidload后,屏幕仍向我显示初始视图控制器

这是关于生命周期,还是根本无法做到这一点

func userNotificationCenter(_ center: UNUserNotificationCenter,
                          didReceive response: UNNotificationResponse,
                          withCompletionHandler completionHandler: @escaping () -> Void) {
    let userInfo = response.notification.request.content.userInfo
    if let messageID = userInfo[gcmMessageIDKey] {
        print("Message ID: \(messageID)")
    }

    let notification = response.notification
    if notification.request.trigger is UNPushNotificationTrigger{
        print("didRecieve Push Notification")
    }else{
        print("did Recieve Local Notification")
    }
    print("notification.requset.identifier: \(notification.request.identifier)")

    self.window = UIWindow(frame: UIScreen.main.bounds)
    let storyboard = UIStoryboard(name:"Main",bundle: nil)
    print(storyboard)
    if let userShowCase = storyboard.instantiateViewController(withIdentifier:"userShowCase") as? userShowCaseViewController {
        print(storyboard)

        self.window?.rootViewController = userShowCase
        self.window?.makeKeyAndVisible()
        userShowCase.performSegue(withIdentifier: "showCase2Login", sender: userShowCase)

    }

    completionHandler()
}

你有没有想过这件事?我也被困在这上面了。你有没有弄明白这一点?我也被卡在上面了。