Webview.android get Undefined in Android

nativescriptcore
android

#1

I get Error as webview.android is undefined as I made Component which is having webview that is extended by setWebChromeClient()
and I have used the same component in subpage that is child page in the first page it works well but in second it get undefined in the same component is there any solution so that I can also get the facility for subpages

 let webview: WebView = this.webViewRef.nativeElement;
if(webview.android || isAndroid) { // in IOS android will be undefined
            console.log("Inside android");
            webview.android.getSettings().setBuiltInZoomControls(false);
            let myWebChromeClient: MyWebChromeClient = new MyWebChromeClient(this.getCookies());
            webview.android.setWebChromeClient(myWebChromeClient);
          }

Here in gettsetting not callled in subpage but it is work in first page

this function is called in onInit method of component


#2

onInit is not the right place to do that, try after view init or the loaded method of webview which guarantees that the native view is created and ready to use.


#3

ok but i have to set cookie too


#4

Thank Done on onLoaded event