Согласно документации филиала, мы должны реализовать это, чтобы перейти к другому представлению, когда пользователь нажимает по глубокой ссылке: < /p>
@main
struct YourAppNameApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL(perform: { url in
Branch.getInstance().handleDeepLink(url)
})
}
}
}
< /code>
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
Branch.getInstance().initSession(launchOptions: launchOptions) { (params, error) in
print(params as? [String: AnyObject] ?? {})
guard let data = params as? [String: AnyObject] else { return }
guard let options = data["nav_to"] as? String else { return }
switch options {
case "landing_page": self.window?.rootViewController?.present( SecondViewController(), animated: true, completion: nil)
case "tutorial": self.window?.rootViewController?.present( SecondViewController(), animated: true, completion: nil)
case "content": self.window?.rootViewController?.present( SecondViewController(), animated: true, completion: nil)
default: break
}
}
return true
}
}
< /code>
Which is fine, except I'm using SwiftUI, so using the window and rootViewController to present a new view is not possible.
And they have no documentation to support SwiftUI.
So what do I need to do to navigate to a view when a user taps on a deep link?
Thanks!
Подробнее здесь: https://stackoverflow.com/questions/785 ... -branch-io