How to activate limitsNavigationsToAppBoundDomains on iOS PWA

Viewed 266

I am building an iOS app and in this app I am using a WKWebview to show an Angular PWA. I want to make sure I activate the PWA features like service workers.

I have researched this and from numerous sources I need use something called limitsNavigationsToAppBoundDomains.

I am using a wkwebview that I have added it in the Interface editor (and not programatically). How can I "configure" this webview?

This is my code. How can I use the configuration part?

import UIKit
import WebKit

    class ViewController: UIViewController {
    
        @IBOutlet weak var webView: WKWebView!
        
        var subdomain:String = ""
        
        override func viewDidLoad() {
            super.viewDidLoad()
            let url = URL(string: "https://\(subdomain).domain.com")!
            
            let configuration = WKWebViewConfiguration()
            configuration.limitsNavigationsToAppBoundDomains = true
            
            webView.load(URLRequest(url: url))
            webView.allowsBackForwardNavigationGestures = false
        }
    
    }
0 Answers
Related