ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
125 stars 111 forks source link

ConnectyCube.videochat is undefined #102

Closed whenmoon closed 4 years ago

whenmoon commented 4 years ago

Something very strange just started happening in my app - I was testing a release build APK and suddenly incoming calls stopped triggering. I went back to a debug build to isolate the problem and discovered that ConnectyCube.videochat is undefined. I have my ConnectyCube call event listeners wrapped in a conditional that checks for ConnectyCube.videochat:

const useListeners = () => {

  const dispatch = useDispatch();

  const setUpListeners = () => {
    console.log('%c ConnectyCube', 'color: green;', ConnectyCube); // defined
    console.log('%c ConnectyCube.videochat', 'color: green;', ConnectyCube.videochat); // undefined
    if (ConnectyCube.videochat) {
      ConnectyCube.videochat.onCallListener = (...args) => {
        dispatch(incomingCall(...args));
      }

However on inspecting the ConnectyCube object, videochat is defined:

Screenshot 2020-07-26 at 14 10 50

I am logging one after the other like this:

Screenshot 2020-07-26 at 14 13 36

I upgraded ConnectyCube from v3.0.1 to v3.6.0 but still have the same problem.

What could be causing the issue?

Thanks

whenmoon commented 4 years ago

Ok I've just fixed the issue - it was a race condition - needed to finish connecting to chat for the object to be defined.