nativescript-webview-interface icon indicating copy to clipboard operation
nativescript-webview-interface copied to clipboard

"Uncaught TypeError: Cannot read property '_onNativeEvent' of undefined"

Open devyaz opened this issue 6 years ago • 14 comments

i get this in console @shripalsoni04 chromium: [INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property '_onNativeEvent' of undefined", source: (1) heres my system info $ tns info All NativeScript components versions information ┌──────────────────┬─────────────────┬────────────────┬─────────────┐ │ Component │ Current version │ Latest version │ Information │ │ nativescript │ 3.4.1 │ 3.4.1 │ Up to date │ │ tns-core-modules │ 3.4.0 │ 3.4.0 │ Up to date │ │ tns-android │ 3.4.1 │ 3.4.1 │ Up to date │ │ tns-ios │ 3.4.1 │ 3.4.1 │ Up to date │ └──────────────────┴─────────────────┴────────────────┴─────────────┘ am using vanilla Javascript

devyaz avatar Jan 25 '18 09:01 devyaz

I'm having the same problem.

m-abs avatar Mar 15 '18 09:03 m-abs

i am having the same issue ...

dotnetdreamer avatar Mar 21 '18 07:03 dotnetdreamer

I solved it by cloning the demo and including the folder ‘www’ from the demo into my App, then modify the ‘www/index.js’ to my liking(am using leafletjs for my Map, so I get events from the map and to the map from {N}) hope it helps

From: Idrees Khan [mailto:[email protected]] Sent: March 21, 2018 09:01 AM To: shripalsoni04/nativescript-webview-interface [email protected] Cc: devyaz [email protected]; Author [email protected] Subject: Re: [shripalsoni04/nativescript-webview-interface] "Uncaught TypeError: Cannot read property '_onNativeEvent' of undefined" (#26)

i am having the same issue ...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/shripalsoni04/nativescript-webview-interface/issues/26#issuecomment-374848256 , or mute the thread https://github.com/notifications/unsubscribe-auth/ATfQSZ2th8aAYiw9qWy6cVwPBCrzLIDMks5tgfq6gaJpZM4Rsla0 . https://github.com/notifications/beacon/ATfQSWm1_3pTaeaIR1aCGa4EnbF27MtIks5tgfq6gaJpZM4Rsla0.gif

devyaz avatar Mar 21 '18 09:03 devyaz

Hello. I have the same issue on iOS device. It fails because the javascript local file cannot be loaded. I have followed the solution in this comment and it works. https://github.com/NativeScript/NativeScript/issues/6377#issuecomment-433322681

xuanhungttm avatar Oct 26 '18 16:10 xuanhungttm

Nothing Work for me this error comes once in a while

himanshukk81 avatar Jul 21 '20 08:07 himanshukk81

hi, you need nativescript-webview-interface in your www folder or just clone it and use the www folder in your app or clone my repo Nativescript-Leaflet-Map as a working example you need a Mapbox Mapbox signup access token insert it into the index.html file

devyaz avatar Jul 21 '20 13:07 devyaz

@devyaz , does the HTML file needs to be available locally?

ejlocop avatar Mar 02 '21 02:03 ejlocop

yes it has, i didn't test hosted file, but i believe it should work

On Tue, 2 Mar 2021 04:44 Eric Locop, [email protected] wrote:

@devyaz https://github.com/devyaz , does the HTML file needs to be available locally?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shripalsoni04/nativescript-webview-interface/issues/26#issuecomment-788533503, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE35ASLOVMBGZTMWOLMAMGDTBRGJ5ANCNFSM4ENSK22A .

devyaz avatar Mar 02 '21 03:03 devyaz

@devyaz , BTW, the plugin does not work on iOS (no logs in the console at all) and on Android, passing data from webview to nativeapp works but not when passing data from nativeapp to webview and showing this error.

Uncaught TypeError: Cannot read property '_onNativeEvent' of undefined

Note: I'm trying to load a hosted page and not a local file.

ejlocop avatar Mar 02 '21 11:03 ejlocop

Someone got news from that ?

kriefsacha avatar Aug 11 '21 10:08 kriefsacha

@ejlocop did you find the solution???

rpragesh avatar Dec 28 '21 06:12 rpragesh

I did back then, but thanks to webpack it doesn't work any more, I've switched to Flutter now trying flutter_webview_plus but I can't get leaflet map to render with local assets, only hosted

devyaz avatar Dec 28 '21 08:12 devyaz

I solved it by cloning the demo and including the folder ‘www’ from the demo into my App, then modify the ‘www/index.js’ to my liking(am using leafletjs for my Map, so I get events from the map and to the map from {N}) hope it helps

From: Idrees Khan [mailto:[email protected]] Sent: March 21, 2018 09:01 AM To: shripalsoni04/nativescript-webview-interface [email protected] Cc: devyaz [email protected]; Author [email protected] Subject: Re: [shripalsoni04/nativescript-webview-interface] "Uncaught TypeError: Cannot read property '_onNativeEvent' of undefined" (#26)

i am having the same issue ...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/shripalsoni04/nativescript-webview-interface/issues/26#issuecomment-374848256 , or mute the thread https://github.com/notifications/unsubscribe-auth/ATfQSZ2th8aAYiw9qWy6cVwPBCrzLIDMks5tgfq6gaJpZM4Rsla0 . https://github.com/notifications/beacon/ATfQSWm1_3pTaeaIR1aCGa4EnbF27MtIks5tgfq6gaJpZM4Rsla0.gif

This was the way I solved it out

devyaz avatar Dec 28 '21 08:12 devyaz

It's a race condition problem. I solve it using a 300ms delay like this:

    setTimeout(function () {
      oWebViewInterface.emit("from-native", { data: "testing" });
    }, 300);

I'm using the latest {N} and android 12.

baysoft avatar Apr 10 '23 14:04 baysoft