shripalsoni04 / nativescript-webview-interface

Plugin for bi-directional communication between webView and android/ios
MIT License
88 stars 35 forks source link

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

Open devyaz opened 6 years ago

devyaz commented 6 years ago

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

m-abs commented 6 years ago

I'm having the same problem.

dotnetdreamer commented 6 years ago

i am having the same issue ...

devyaz commented 6 years ago

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:notifications@github.com] Sent: March 21, 2018 09:01 AM To: shripalsoni04/nativescript-webview-interface nativescript-webview-interface@noreply.github.com Cc: devyaz mtunthama@gmail.com; Author author@noreply.github.com 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

xuanhungttm commented 5 years ago

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

himanshukk81 commented 4 years ago

Nothing Work for me this error comes once in a while

devyaz commented 4 years ago

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

ejlocop commented 3 years ago

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

devyaz commented 3 years ago

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

On Tue, 2 Mar 2021 04:44 Eric Locop, notifications@github.com 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 .

ejlocop commented 3 years ago

@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.

kriefsacha commented 3 years ago

Someone got news from that ?

rpragesh commented 2 years ago

@ejlocop did you find the solution???

devyaz commented 2 years ago

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 commented 2 years ago

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:notifications@github.com] Sent: March 21, 2018 09:01 AM To: shripalsoni04/nativescript-webview-interface nativescript-webview-interface@noreply.github.com Cc: devyaz mtunthama@gmail.com; Author author@noreply.github.com 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

baysoft commented 1 year ago

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.