0

I want to open WhatsappWeb application with WKWebview with a direction I made from within the application.

I successfully redirect and open WhatsappWeb; but webview is constantly opening in desktop view. Any ideas to convert this to mobile view?

I have shared the code below. Thanks in advance.

     let url = URL(string: "https://web.whatsapp.com/")!
    webView.load(URLRequest(url: url))
    webView.navigationDelegate = self
    let userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15"
    webView.customUserAgent = userAgent
    webView.configuration.defaultWebpagePreferences.preferredContentMode = .mobile
    webView.allowsBackForwardNavigationGestures = true
SwiftTry
  • 121
  • 10

0 Answers0