-1

WKWebView in loading this link:- https://moc.e2logy.com/about-us/divisions/foreign-trade-territorial-division/foreign-trade-nafta/

When I am click on below link https://tradestat.commerce.gov.in/eidb/default.asp

Giving error Unknown result for URL 0x600000841f80 (https) https://tradestat.commerce.gov.in/eidb/default.asp

2 Answers2

0

There are a few things you can check:

  1. Verify that the <a href links doesn't contain target="_blank" attribute since WKWebView doesn't know how to open the link in a new tab. see https://stackoverflow.com/a/25853806/810466 for how to work around that.

  2. Check if the link is HTTPS or update the App Transport Security Settings with the Allow Arbitrary Loads option

  3. Make sure that you start the loading request only after adding the WKWebView to the view hierarchy in didMoveToParentViewController: since it may make javascript to fail if it tries to run outside the view hierarchy

  4. Implement the WKWebView NavigationDelegate methods and make sure you return WKNavigationActionPolicyAllow when deciding the policy for the request

Q.u.a.n.g L.
  • 1,564
  • 1
  • 12
  • 27
0

I got issue. issue of access of class of javascript message

func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo,
             completionHandler: @escaping (Bool) -> Void) {
    let attributedString = NSAttributedString(string: message, attributes: [
        NSAttributedString.Key.font : Utility.getFont(fontName: FONT.RobotoRegular, sizeOfFont: FONT_SIZE.FOURTEEN),
        NSAttributedString.Key.foregroundColor : UIColor.black
    ])

    let alertController = UIAlertController(title: nil, message: "", preferredStyle: .alert)
    alertController.setValue(attributedString, forKey: "attributedMessage")
    alertController.view.tintColor = UIColor.black

    alertController.addAction(UIAlertAction(title: LocalizationSystem.sharedInstance.localizedStringForKey(key: "ok", comment: "").uppercased(), style: .default, handler: { (action) in
        self.isExternal = 1
        completionHandler(true)
    }))

    alertController.addAction(UIAlertAction(title: LocalizationSystem.sharedInstance.localizedStringForKey(key: "cancel", comment: "").uppercased(), style: .default, handler: { (action) in
        self.isExternal = 0
        completionHandler(false)
    }))

    present(alertController, animated: true, completion: nil)
    
}

when I am using this method getting success

Thanks