Closed kriefsacha closed 4 years ago
Hey @kriefsacha
Thank you for your bug rapport.
I can't test on iOS 13
before tomorrow or early next week, but the problem might be the WebViewExt
getting a height of 0, because of the StackLayout
.
Could you try with:
<GridLayout rows="*" columns="*" class="page">
<WebViewExt #webView id="webView" (loaded)="webViewLoaded($event)" debugMode="true" style="border:10px solid black"></WebViewExt>
</GridLayout>
And could you test it on the latest tns-core-modules@6.1.1
and tns-ios@6.1.1
-runtime?
Hey @m-abs , sorry for the long time It took me to answer.
It actually worked. I just have a little problem now. When I send javascript to the WebView like 'document.location' it's working. But when I send for loop or something it's not working anymore. Here an exemple when I only do a variable and try to return it.
Exemple :
this.webViewInterface.on(WebViewExt.loadFinishedEvent, (args2: LoadFinishedEventData) => {
if (this.isOn === false) {
this.isOn = true;
console.log('now');
this.webViewInterface.executeJavaScript("var x = 0; x;").then(res => {
console.log('res ' + res);
})
}
})
Error message :
CONSOLE ERROR file:///node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:676:0: Unhandled Promise rejection: Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=5, WKJavaScriptExceptionMessage=SyntaxError: Unexpected keyword 'var', WKJavaScriptExceptionColumnNumber=0, WKJavaScriptExceptionSourceURL=https://m.facebook.com/?refsrc=http%3A%2F%2Fwww.google.com%2F&_rdr, NSLocalizedDescription=A JavaScript exception occurred} ; Zone:
; Task: Promise.then ; Value: Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=5, WKJavaScriptExceptionMessage=SyntaxError: Unexpected keyword 'var', WKJavaScriptExceptionColumnNumber=0, WKJavaScriptExceptionSourceURL=https://m.facebook.com/?refsrc=http%3A%2F%2Fwww.google.com%2F&_rdr, NSLocalizedDescription=A JavaScript exception occurred} undefined
@kriefsacha
Good to hear that it helped :)
The new problem is probably caused an undocumented behavior...
If you need the result of an executed JavaScript and it is more than one function-call (or declares a var) you need to warp the code as a function with a return value. Something like this:
(function() {
var x = 0;
/// DO WORK
return x;
}();
This is because the code is assigned to a value, so the result can be returned from the webview-layer to the nativescript-layer.
@m-abs
You were missing a parenthesis at the last line to close the function , but yes it works.
Thank you a lot for your help. I will tell you if I have other scripts that are not working.
Thanks !
Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
tns --version
to fetch it) 6.1.2node --version
to fetch it) 10.16.2npm ls tns-core-modules
in your project to fetch it.) 6.0.1"tns-android"
and"tns-ios"
properties in thepackage.json
file of your project) tns-ios 6.0.1package.json
file of your project and paste your dependencies and devDependencies here)Please, tell us how to recreate the issue in as much detail as possible.
Describe the steps to reproduce it.
I just created a new project. Puted the webview and code I saw on your readme. On IOS nothing is appearing , on android it's working fine. I see all the consoles logs , even of the callback of the javascript sent to the web view but nothing appears at all.
Is there any code involved?
This is the home page of the app (first page appearing) HTML
TS
Screenshot result