0

I am developing an iPhone/iPad App using phonegap/cordova.

Now as i have to integrate some devices which are having SDK for xcode supportable.The issue i am facing is that i wanted to call javascript function from my native functions. I know how to call native funciton from javascript but looking for vice-versa.

I have searched alot over internet but they all are describing how to do it by using webview. I don't want to use webview as i am not familier with objective-c coding and also for that i have to change my HTMl Code into webview as my code is fully developed in HTML5 and javascript by using cordova plugin.

Please suggest me if any other way is also available.

2
  • If you want to call JavaScript from native code, you will have to write native code. Commented Jan 7, 2013 at 14:10
  • i have native code written but i want to know how can i from native code javascript function can be called? like native function can be called from javascript by writing the plugin but how can vice versa be possible. Commented Jan 7, 2013 at 14:43

2 Answers 2

1

You can call a javascript function from native code like this:

    [self.webview stringByEvaluatingJavaScriptFromString:@"myfunc();"];
Sign up to request clarification or add additional context in comments.

2 Comments

This is through webview but i am developing through the phonegap.
Then you should folow this approach: stackoverflow.com/questions/11609326/…
0

Old question but my first hit on Google. So I give it a try. You have to call self.commandDelegate evalJS. Other methods like writeJavascript are deprecated.

Inside your plugin-code call

[self.commandDelegate evalJs:@"console.log('Greetings from Native');"];

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.