是否可以从后台模式或应用程序被终止时打开 ViewController?

Is it possible to open ViewController from background mode or when app is killed?

我正尝试在收到推送通知时打开 ViewController。我是这样做的

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
    guard let aps = payload.dictionaryPayload[AnyHashable("aps")] as? NSDictionary else {
        return
    }
    startCustomCallController(apnData: app)
}

func startCustomCallController(apnData: NSDictionary) {
    let storyBord = UIStoryboard(name: "PrivateUi", bundle: nil)
    guard let controller = storyBord.instantiateViewController(withIdentifier: "NewIncomingCallViewController") as? NewIncomingCallViewController else{
        print("Error instantiating view controller")
        return
    }
    controller.apnData = apnData
    guard let appdelegate = UIApplication.shared.delegate as? AppDelegate else {
        print("appdelegate is missing")
        return
    }
    UIView.transition(with: appdelegate.window!, duration: 0.5, options: .transitionCrossDissolve, animations: {
        appdelegate.window!.rootViewController = controller
    }, completion: nil)
}

它在应用程序打开时工作(在前台)但在后台或被杀死时不工作。 是不可以还是我需要做一些改变?

我认为 ViewController 无法从背景模型启动。如果要开启viewcontroller调用相关任务连击使用callkit

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) {
    // report new incoming call
}```