Giter Club home page Giter Club logo

Comments (16)

lesnitsky avatar lesnitsky commented on May 29, 2024

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.

lesnitsky avatar lesnitsky commented on May 29, 2024

Might be realted to facebook/react-native#11594

from react-native-webview-messaging.

lesnitsky avatar lesnitsky commented on May 29, 2024

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.

468910 avatar 468910 commented on May 29, 2024

Okay was just writing up an explanation, but now I will look into this.

image

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.

React
image

React-Native
image

No non-trivial usecase so far, just connecting native components like facebook, firebase IAP etc.

from react-native-webview-messaging.

lesnitsky avatar lesnitsky commented on May 29, 2024

can you also share your import statement of message channel? (webview js, not react native)

from react-native-webview-messaging.

468910 avatar 468910 commented on May 29, 2024

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.

lesnitsky avatar lesnitsky commented on May 29, 2024

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.

468910 avatar 468910 commented on May 29, 2024

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.

lesnitsky avatar lesnitsky commented on May 29, 2024

Thanks for highlighting this issue and welcome v0.4.1 😏

BTW, was your android issue resolved?

from react-native-webview-messaging.

468910 avatar 468910 commented on May 29, 2024

Not yet we are going to try the timeout and try your example. I will update here asap.

from react-native-webview-messaging.

468910 avatar 468910 commented on May 29, 2024

screenshot_1501862930

Example gives me this warning.
ran react-native link.

from react-native-webview-messaging.

lesnitsky avatar lesnitsky commented on May 29, 2024

Is it example from this repo as is or did you add some modules you use in your app?

from react-native-webview-messaging.

468910 avatar 468910 commented on May 29, 2024

Just the example as is.

from react-native-webview-messaging.

lesnitsky avatar lesnitsky commented on May 29, 2024

react-native --version

from react-native-webview-messaging.

468910 avatar 468910 commented on May 29, 2024

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.

lesnitsky avatar lesnitsky commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.