Skip to content

WebView element error undefined is not an object (evaluating 'this.oLangWebViewInterface.callJSFunction' #49

Description

@BJacob7

hi , since i upgrade my env to nativescript 6.0.0 im having trouble to run webview
im getting and error on callJSFunction
undefined is not an object (evaluating 'this.oLangWebViewInterface.callJSFunction')

import { WebView, LoadEventData } from 'tns-core-modules/ui/web-view/'; create : let webViewInterfaceModule = require('nativescript-webview-interface');

hild: @ViewChild('installationWebView', {static: false}) webView: ElementRef;

object: private oLangWebViewInterface;

ngAfterViewInit() {

this.setupWebViewInterface();

}

function private setupWebViewInterface() {
let webView: WebView = this.webView.nativeElement;
this.oLangWebViewInterface = new webViewInterfaceModule.WebViewInterface(webView, '~/www/index.html');

if (webView.android) { // in IOS android will be undefined
    webView.android.getSettings().setBuiltInZoomControls(false);
}

// loading devices in dropdown, on load of webView.
webView.on(WebView.loadFinishedEvent, (args: LoadEventData) => {
    let message: string;
    if (!args.error) {
        message = `WebView finished loading of ${args.url}`;

    } else {
        message = `Error loading ${args.url} : ${args.error}`;
    }
    console.log(`WebView message - ${message}`);
});

this.listenLangWebViewEvents();

}

connect to device function :

private connectToDevice() {
//this.isConnecting = true;
this.oLangWebViewInterface.callJSFunction('connectToDevice', null, (response: any) => {
console.log(JSON.stringify(response));

});

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions