Huy Nguyen
Huy Nguyen

Reputation: 77

evaluateJavaScript() with Error Domain=NSCocoaErrorDomain Code=3840 just on iPhone 5 - iOS 10.3.3

I want ti evaluateJavaScript() which is a function from WKWebView I get the error with detail is:

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

Can any one met this problem? Hope to your share.Thanks!

Upvotes: 0

Views: 102

Answers (1)

Raj Aggrawal
Raj Aggrawal

Reputation: 761

You can check the JavaScriptCore framework to evaluate JavaScript. it is native iOS framework.

let context = JSContext()

let _ = context?.evaluateScript(evaluateScriptJSCode)

let method = context?.objectForKeyedSubscript("methodToCallInJavaScript")

let result = method?.call(withArguments: [params])

Upvotes: 1

Related Questions