Repository navigation
🤔 Does This Project Support @JavascriptInterface-like Annotations for JS-Native Communication? #306
Replies: 2 comments
|
@KevinnZou You talk about a customization of the method name here: #80 (reply in thread) Is it still planned ? |
|
In the 2.0.3 bridge API, registration is through If your existing frontend API is callback-based, a small compatibility layer can preserve its call sites. For example, to retain window.Native = window.Native || {};
window.Native.greet = function (message, onResult) {
window.kmpJsBridge.callNative(
"Greet",
JSON.stringify({ message }),
onResult
);
};Register a Kotlin handler whose One limitation matters: an existing synchronous call such as |
Uh oh!
There was an error while loading. Please reload this page.
I noticed the documentation mentions JS-Native interaction only through window.kmpJsBridge.callNative. While the JsBridge name is configurable, it appears restricted to using the callNative method pattern.
In Android projects, we use @JavascriptInterface annotations to expose native methods directly to JS. Does this project support similar annotation-driven approaches?
Though JS function mapping could be a workaround, is there a zero-configuration solution that preserves existing frontend code? I'm looking for a way to achieve bidirectional communication without rewriting existing JS invocation logic.
All reactions