Comments (16)
Hey,
Thanks for feedback!
Could you please share your code example which is not working for you? Might be some non-trivial case or smth. Android version works fine for me, so need to investigate your issue
from react-native-webview-messaging.
Might be realted to facebook/react-native#11594
from react-native-webview-messaging.
Check out this example. Tested it on android, works fine (however I had no chance to launch expo example on android, but actually I had never able to make android work with expo on my dev machine 😀)
from react-native-webview-messaging.
Okay was just writing up an explanation, but now I will look into this.
The screenshot shows that the RNMessageChannel is there (the reference is always RnMessageChannel.window even though its imported in React as RNMsgChannel).
So the message channel is loaded but its not reachable by the code on time which goes back to the issue you referred to.
No non-trivial usecase so far, just connecting native components like facebook, firebase IAP etc.
from react-native-webview-messaging.
can you also share your import
statement of message channel? (webview js, not react native)
from react-native-webview-messaging.
In our React Project:
import RNMsgChannel from "react-native-webview-messaging";
Also tried
const RNMsgChannel = window.RNMessageChannel
quick note you used RNMessagesChannel in the readme, RNMessageChannel.window for exporting and RNMsgChannel in importing 😄.
Does the problem lie there?
from react-native-webview-messaging.
the reason why you can't reach RNMsgChannel
variable from devtools console is that webpack wraps each module into function and this prevents variable from leaking to global scope. If you want to have access to this variable, make explicit assignment to window.
import WhateverNameYouLike from 'react-native-webview-messaging';
window.WhateverNameYouLike = WhateverNameYouLike;
quick note you used RNMessagesChannel in the readme, RNMessageChannel.window for exporting and RNMsgChannel in importing 😄
The reason why I've used different naming in example is to demonstrate that you can name this channel whatever you like, it'd still be working. Ideally you shouldn't be aware of global variable named RNMessageChannel
and take it in account. Use commonjs/es6 modules and names you like 😄
but yeah, you're right, there is a typo in README 👍
from react-native-webview-messaging.
Yeah thats what i figured thats why I'm wondering why you asked about the import as the module always exports to window.RNmessageChannel. That screenshot shows some late night programming ;) However it displays the problem thats why i attached it.
from react-native-webview-messaging.
Thanks for highlighting this issue and welcome v0.4.1
😏
BTW, was your android issue resolved?
from react-native-webview-messaging.
Not yet we are going to try the timeout and try your example. I will update here asap.
from react-native-webview-messaging.
Example gives me this warning.
ran react-native link.
from react-native-webview-messaging.
Is it example from this repo as is or did you add some modules you use in your app?
from react-native-webview-messaging.
Just the example as is.
from react-native-webview-messaging.
react-native --version
from react-native-webview-messaging.
react-native-cli: 2.0.1
react-native: 0.47.1
Anyway I gave up I opted to rewrite our wrapper in Native Android.
This is working for me with the same React Setup I was using.
I still haven't been able able to fix it for now I wont spend anymore time on this however.
I will keep using it for IOS though 👍
from react-native-webview-messaging.
Most likely you have some issues with your dev env as I've tested android setup on 2 machines and everything works as expected...
from react-native-webview-messaging.
Related Issues (20)
- Unexpected token / in JSON at postion 0 HOT 11
- Android 4.4.4 below, react native cannot call the web side method HOT 2
- Failed to execute 'postMessage' on 'Window': 2 arguments required, but only 1 present HOT 2
- Setting onMessage on a WebView overrides existing values of window.postMessage HOT 9
- Event call on Android but not on iOS HOT 3
- await connectToRemote() not returning a connection or error HOT 4
- (V1) Cannot run on Android HOT 2
- Is there an example to send data to RN in pure html/js and not generated? HOT 1
- cant debug. missing setWebContentsDebuggingEnabled(true) method HOT 1
- webview messagesChannel not working on event listener callback
- file miss HOT 1
- Migrate to latest react native version
- The input type file does not work in webview. from android
- Doesn't seem to work on iOS 9.3 HOT 3
- react-native bundling fails when `require`-ing a html file HOT 6
- onPermissionRequest HOT 2
- Can you provide a working HTML? HOT 1
- "Module JSTimersExecution is not a registered callable module (calling callTimers)" Error HOT 3
- Migrate expo example to v20 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-webview-messaging.