Notalib / nativescript-webview-ext

Nativescript plugin with extended WebView functionality
Apache License 2.0
76 stars 37 forks source link

Missing events from webview #80

Closed ray007 closed 3 years ago

ray007 commented 4 years ago

Missing events

Event handlers for titleChanged and shouldOverrideUrlLoading do not get called.

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

In app.js I have

import * as wvx from "@nota/nativescript-webview-ext/vue";

And in the vue-component: <WebViewExt ref="wvx" :src="url" v-bind="wvxProps" v-on="wvxEv"/>

I'm setting wvxProps and wvxEv in the component's created handler:

        this.wvxEv = {
            loadStarted: ev => {
                console.log('load started');
            },
            loadFinished: ev => {
                console.log('load finished');
            },
            titleChanged: title => {
                console.log('title', title);
            },
            shouldOverrideUrlLoading: (url, arg) => {
                console.log('url ovr', url, arg);
            }
        };

The handlers for loadStarted and loadFinished get called, the other 2 do not. Haven't yet tested with the remaining documented events. I know that the document title get changed since I checked with getTitle() in the loadFinished handler, and I know that http requests get made since I see their result displayed in the webview.

I also tried to go with

this.$refs.wvx.nativeView.on('titleChanged', ...);

but no luck with that either.

Any idea what I'm doing wrong?

ray007 commented 4 years ago

Update: I'm getting the shouldOverrideUrlLoading when loading a local html/js app, through I have no idea where args.cancel would be found. And I guess it's only for dealing with the frame loading url, not XmlHttpRequests made from the js app? Still no titleChanged event.

m-abs commented 4 years ago

Hmmm, looks like a bug with the native webview...

keithoys commented 3 years ago

titleChanged does not get called on iOS too. I'm on "@nota/nativescript-webview-ext": "^6.5.5".