Call Objective-C from Safari javascript?

195 views Asked by At

On OSX (say Yosemite), I'd like a way to call Objective-C from Safari/Javascript. Is there a way to do this?


Not what I'm looking for:

  • embed a WebView/WKWebView in an app
  • Start/control/load Safari from Objective-C
  • use JXA outside of Safari (unless it connects in a way that let's me bridge to Objective-C from inside-Safari javascript).
2

There are 2 answers

1
Theodore Norvell On BEST ANSWER

I came across this reference. So the answer appears to be: yes if you are writing a plugin.

https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/SafariJSProgTopics/ObjCFromJavaScript.html

0
Michael Fry On

No. There is no way to do this. The only interface to the client machine is the API which the browser provides.