cowbell / cordova-plugin-geofence

Geofencing plugin for cordova
Apache License 2.0
265 stars 316 forks source link

Error in new iOS code for JS function #122

Closed timwright35 closed 8 years ago

timwright35 commented 8 years ago

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 commented 8 years ago

Anyone have the solution?

timwright35 commented 8 years ago

Not yet, I have been working on figuring it out

timwright35 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

I have ios 3.9.2 it seems

johnrobertcobbold commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

@Tempus35, for reasons explained here https://github.com/cowbell/cordova-plugin-geofence/issues/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 commented 8 years ago

@johnrobertcobbold Good to know