Search code examples
javascriptiosswift3safariuiwebview

IOS WKWebView and UIWebView isn't loading JavaScript Sign Up form while Safari does


In Safari my Sign Up form JavaScript code works fine, but in UIWebView and in WKWebView that form isn't loading.

Here is my Code to review.

import UIKit
import WebKit


class ViewController: UIViewController, WKNavigationDelegate {

@IBOutlet weak var Webview: UIWebView!

var webView: WKWebView!
var websites = ["lampecompany.com", "lampecompany.com"]

override func loadView() {
    webView = WKWebView()
    webView.navigationDelegate = self
    view = webView
}
override func viewDidLoad() {
    super.viewDidLoad()

    let url = URL(string: "https://" + websites[0])!
    webView.load(URLRequest(url: url) as URLRequest)
    webView.allowsBackForwardNavigationGestures = true

}

Main page opens correctly and then Menu -> Apply, on this screen Apply here form doesn't display.

Here are both screenshots attached. Safari and WKWebView.

enter image description here enter image description here

Any help regarding this that my WKWebView start behaving like Safari and open each and everything correctly as Safari browser does.

When I put my website link here in this WKWebView browser then its working. https://github.com/mbarnig/WKWebView

so why not in my code. I used the same code in my app but in vein.

Thank you in Advance!


Solution

  • Your web page Signup form (iframe) has SSL issue.

    In iOS, If you are loading an http url, then you have to add App Transport Security Settings in your info.plist file.

        <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
        </dict>
    

    I found the issue in the following way.

    1. Enable Safari Developer mode Safari-> Preference -> Advanced -> Show Developer option on Menu.
    2. Run your app on simulator and Open Safari browser on your Mac.
    3. Go to Developer menu -> Simulator -> Select your site url.
    4. You will get the console log of your web page.

    Please see your web page console log below.

    enter image description here

    Error : Failed to load resource: An SSL error has occurred and a secure connection to https://www.lampeplacementservices.com/LampeOptin/LampeOptinReferralForm.html