This is a yes/ no question.
I did a bunch of research on "angular 4 in webview" etc. but all I found was Andriod Studio related like this question and nothing related to NativeScript. Angular Browser Support shows that Angular is supported on iOS from v7 and on Android from v4.1 which makes me think that Angular4 app should run normally in a WebView. But the lack of examples and failures at our tests urge me to ask if this is even supported or not?
Hi @Kampii,
Thank you for your interest in NativeScript.
Ths NativeScript WebView is a common abstraction for the native Android and iOS WebViews. Regard that everything that is supported by the native component should be available also in NativeScritp.
Regarding the issue, you are facing. I think that you need only to access the webView setting for Android and to enable the javascript and the dom storage. For example:
var myWebView = page.getViewById("my-web-view");
myWebView.android.getSettings().setJavaScriptEnabled(true);
myWebView.android.getSettings().setAppCacheEnabled(true);
myWebView.android.getSettings().setDomStorageEnabled(true);
For further questions, I would recommend using NativeScript forums or StackOverflow.
@tsonevn I don't know whether my question is relevant to the post but when i tried the same, I am getting the below error
ERROR TypeError: Cannot read property 'getSettings' of undefined
I checked in debugger and myWebView.android is undefined.
I have also tried
android.webkit.WebView.getSettings().setJavaScriptEnabled(true);
android.webkit.WebView.getSettings().setAppCacheEnabled(true);
android.webkit.WebView.getSettings().setDomStorageEnabled(true);
and that says ERROR TypeError: android.webkit.WebView.getSettings is not a function
Hi @nmongiya,
Please provide more info about your problem.
It would help if you provide a sample project, which could be debugged locally or at least send us the code, which shows, how you get the reference to the WebView.
haha i have been trying to solve this issue for like 3 days and i finally googled the right thing...
I am facing the same issue, my app is on angular 6 and cant open in webview, Please share the solution
I am facing a issue, my app is working fine in android webview but, http calls are not working.
Hi @dhavalsolanki,
Can you provide more info about the problem, which you are facing? It will help if you send us sample project, which can be used for debugging.
@nmongiya
onWebViewLoaded(event: any) {
const webView: WebView = <WebView>event.object;
webView.android.getSettings().setJavaScriptEnabled(true);
webView.android.getSettings().setAppCacheEnabled(true);
webView.android.getSettings().setDomStorageEnabled(true);
}
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I am facing the same issue, my app is on angular 6 and cant open in webview, Please share the solution