更新时间:2022-01-02 22:59:13
SceneDelegate
可以通过以下方式处理通知响应:
SceneDelegate
can handle notification response this way:
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
// rootViewController set up code
// say,
// let mainController = ViewController()
// let navigationController = UINavigationController(rootViewController: mainController)
// window.rootViewController = navigationController
// This is UNNotificationResponse
if let notificationResponse = connectionOptions.notificationResponse {
window.makeKeyAndVisible()
// do the pushing on your navigation controller
// navigationController.push()
return
}
window.makeKeyAndVisible()
}
}
}