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

Error in new iOS code for JS function #122

Closed
timwright35 opened this issue Feb 18, 2016 · 9 comments
Closed

Error in new iOS code for JS function #122

timwright35 opened this issue Feb 18, 2016 · 9 comments

Comments

@timwright35
Copy link

As the title says, there is a code error in the executeJS function for the new iOS code, I have tried fixing it but apparently I do not know swift2 very well.

@jlamim
Copy link

jlamim commented Feb 18, 2016

Anyone have the solution?

@timwright35
Copy link
Author

Not yet, I have been working on figuring it out

@timwright35
Copy link
Author

I changed my function to: (It gives warnings but seems to work for me, likely needs someone else to update it better)

func evaluateJs (script: String) {
        if webView != nil {
            if let uiWebView = webView! as? UIWebView {
                uiWebView.stringByEvaluatingJavaScriptFromString(script)
            } else if let wkWebView = webView as? WKWebView {
                wkWebView.evaluateJavaScript(script, completionHandler: nil)
            }
        } else {
            log("webView is null")
        }
    }

@johnrobertcobbold
Copy link

@Tempus35 Are you using Cordova IOS 4 and therefore maybe wkWebView ? If so, I can confirm that things are working. If you are using uiWebView, I do not know then but I am sure someone else can feedback,

@timwright35
Copy link
Author

I have ios 3.9.2 it seems

@johnrobertcobbold
Copy link

cordova platforms ls will let you know which version you are using for ios.
If it is < 4, you are definitively using uiWebView.

Not the answer to your problem, but wkWebView brings a nice speed improvement, you can consider upgrading (just make sure you other plugins have been upgraded by their authors to be compatible with it)

@timwright35
Copy link
Author

Yes I am less than 4 but at the time this app is on crunch time and being it is working fine except for some slight issues with geofencing on iOS I am not going to try to upgrade yet.

@johnrobertcobbold
Copy link

@Tempus35, for reasons explained here #127, I had to stop using wkWebView and went back to uiView. I can now confirm your bug and the fix you mentioned above.

@timwright35
Copy link
Author

@johnrobertcobbold Good to know

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

No branches or pull requests

3 participants