-1

I have a requirement where I have to inject a objective c code into web view which contains html, css and js code?

Brief:
WL needs also injects a Native Interface to the Webview named "INTERFACE" to expose following values present in Native environemt to hybrid screen. These values are can be obtained in hybrid using functions.

Values are:

  1. Version (Version Number of application exposed through getVersion() method)
  2. platform: android/iphone (To tell hybrid in which mode to operate and use the same value for Adapter calling. Exposed through getPlatform() method)
  3. debugMode: true/false (To tell hybrid that application is running in debug mode. Exposed through isDebugMode() method)

Is there a way to do it in ios? If so, How can the same be achieved?

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Rahul Singh
  • 103
  • 1
  • 10
  • You can't inject iOS into HTML, YES you can interact between both of them, you can call javascript function directly from iOS, you can call iOS function on any html behavior. See this http://stackoverflow.com/questions/15983797/can-a-uiwebview-interact-communicate-with-the-app – iphonic Aug 04 '14 at 09:31
  • You write that "they are present in native" and that you want to "expose them in hybrid", but then you write that they can be "obtained in hybrid", so why do you want to move them from native hybrid to begin with? Your text is not clear. – Idan Adar Aug 04 '14 at 10:00
  • Explain in plain wording what are you trying to do. – Idan Adar Aug 04 '14 at 10:01

1 Answers1

0

To do what I think you are trying to do you will need to use UIWebView’s -stringByEvaluatingJavascriptWithString: method. Get the native data you need in your objective c class and use that method to pass in json data etc for consumption in the web view.

savner
  • 830
  • 6
  • 7
  • I tried doing that but I am getting "Uncaught Exception: ReferenceError: Can't find variable: JsInterface at (compiled_code):1" error. – Rahul Singh Aug 04 '14 at 14:16