How can I present a view controller in my UserActionManager class from a userActivity?
I am using Universal Links and have set up the apple-app-site-association file.
When I have found the userActivity.webPageURL.lastPathComponent equal to "registration" I would like to push to the RegistrationViewController.
Currently I've created a separate singleton called UserActionManager where I would like to handle lastPathComponents and present the correct View Controller.
In UserActionManager I can successful hit handleRegistrationUserActivity
but need to add logic or a protocol to display the related ViewController.
AppDelegate:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
guard let url = userActivity.webpageURL, userActivity.activityType == NSUserActivityTypeBrowsingWeb else {
return false
}
UserActionManager.shared.handleUserActivity(from: url)
return true
}
UserActionManager:
class UserActionManager {
// MARK: - Singleton
static let shared = UserActionManager()
func handleUserActivity(from url: URL) {
switch url.lastPathComponent {
case "registration":
handleRegistrationUserActivity()
default:
break
}
}
private func handleRegistrationUserActivity() {
// TODO: Set the root navigation controller to RegistrationViewController()
}
}