Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access webview with TurboNavigator? #222

Open
bibstha opened this issue Jul 11, 2024 · 1 comment
Open

How to access webview with TurboNavigator? #222

bibstha opened this issue Jul 11, 2024 · 1 comment

Comments

@bibstha
Copy link

bibstha commented Jul 11, 2024

This may be due to stale documentation.
Looks like the TurboNavigator branch is the most active branch. The QuickStart says the

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    var window: UIWindow?
    private let navigator = TurboNavigator()

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let _ = (scene as? UIWindowScene) else { return }
        window?.rootViewController = navigator.rootViewController
        navigator.route(baseURL)

With this, the Session object and the webView object are encapsulated inside TurboNavigator.
If I want to set configs to webView, eg: webView.allowsLinkPreview = false, how do I do that?

@iamjohnford
Copy link

I'm not sure if this is the best way, but if you're using the demo code, you can insert webView.allowsLinkPreview = false into the section that creates the custom webView:

Turbo.config.makeCustomWebView = { config in
config.defaultWebpagePreferences?.preferredContentMode = .mobile
let webView = WKWebView(frame: .zero, configuration: .appConfiguration)
if #available(iOS 16.4, *) {
webView.isInspectable = true
}
// Initialize Strada bridge.
Bridge.initialize(webView)
return webView
}

Another option specifically for link previews is CSS. If you're targeting turbo native in your HTML tag, you can do something like this:

html[data-turbo-native] {
  -webkit-touch-callout: none;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants