0

I want to build a java script bridge for my app.

Through that bridge I want to call js's method, also want to call application's method from js. Can anyone help me with any suggestion?

Thanks

2 Answers 2

1

To call the JS function from native code,

 [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"NAME_OF_JS_FUNCTION('ARGUMENT')",configJson]];

To call native function from JS,

window.location = "js-call:"+obj;

It will invoke your webview delegate method.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I think it will work. And I also found a post with brief description to call native function from JS.
0

If you don't mind waiting a couple months, check out the Javascript video at https://developer.apple.com/wwdc/videos/.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.