Need help: How extends in nativescript only one method with interface android (like JavascriptInterface)


I need write in Nativescript as android like

public class JivoInterface{
    public void send(String name, String data){
        if (delegate != null){
            delegate.onEvent(name, data);


webView.addJavascriptInterface(new JivoInterface(webView), "JivoInterface"); 

My code

  var JivoInterface = java.lang.Object.extend({
        interfaces: [android.webkit.JavascriptInterface],
        send: function(name: string, data: string){
            _self.ckickUrl(name, data);
        toString() { return "JivoInterface"; }

And i have got error Uncaught TypeError: Object [object Object] has no method 'send'

How I can add implement the @JavascriptInterface for one method in class?


According to the Java code JivoInterface is a class.

And in the javascript code you try to implement the android.webkit.JavascriptInterface, which by the way has no method ‘send’, because it’s an annotation.


How I can add it annotation in javascript? (I found nothing in documentation )


You cannot use annotations currently in JavaScript. Java annotations can be applied to classes, methods, variables, packages. They are something that have no natural representation, or use case in JavaScript.