ConnectyCube / connectycube-reactnative-samples

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

Error on app reload in react native #297

Closed enggomarpu closed 1 year ago

enggomarpu commented 2 years ago

Hello, Hope you are doing great. I am implementing connnectycube for a react native app. When I first time login to my app, video call functionality works fine. When I reload my app and push start call button again I get this error 'null is not an object (evaluating 'client.jid._local')'. I make sure my session is stored to the local storage. I am also updating session on app reload though using this code.

Versions "react-native": "0.68.0", "react-native-webrtc": "^1.100.1" "react-native-connectycube": "^3.18.0",

useEffect(() => { getItem('ConnectyCube:session').then((storedSession) => { console.log('storedSession', storedSession) if(storedSession){ const session = JSON.parse(storedSession); ConnectyCube.setSession(session); } }).catch(() => { Alert.alert('Error in reading local storage') }) }, [])

Any suggestions or help, am i doing missing something or doing wrong ?

DaveLomber commented 2 years ago

In order to perform calls, you need to be connected to chat

This is stated here https://developers.connectycube.com/js/videocalling?id=preparations

'null is not an object (evaluating 'client.jid._local')'. means you are not connected to chat

enggomarpu commented 2 years ago

Ok. @DaveLomber I got your point and solved the issue by calling login method written in auth-service.js file for react-native video calling sample code on every app reload.

I get this error [TypeError: undefined is not an object (evaluating 'this.streamManagement.elementHandler')] when i call ConnectyCube.chat.disconnect() on logout button of my app

DaveLomber commented 2 years ago

@enggomarpu hm, it's hard to say what's the reason could you post the complete stack trace

enggomarpu commented 2 years ago

@DaveLomber This is the error, I am getting when I calls ConnectyCube.chat.disconnect(). I am implementing one to one video call and following sample video call code.

Screen Shot 2022-06-02 at 5 12 30 PM

`disconnect() { Utils.DLog('[Chat]', 'disconnect'); if (this._isLogout) { Utils.DLog('[Chat]', 'Warning! Chat is already disconnected!'); return; }

this.muc.joinedRooms = {};
this.isConnected = false;
this._isConnecting = false;
this._isLogout = true;
this._isReconnect = false;
this.helpers.setUserCurrentJid('');

if (this.streamManagement.elementHandler) {
  this.xmppClient.removeListener('element', this.streamManagement.elementHandler)
}
return this.xmppClient.stop();

}`

This the function called in your cubeChat.js. Please share your thoughts, how can I avoid this error or remove this error.

DaveLomber commented 2 years ago

@enggomarpu I see

can you try to use the following SDK config and see if the issues persists:

const CONFIG = { "chat": {
      "streamManagement": {
        "enable": true
      }
    },
      "debug": {
        "mode": 1
      } 
 }

ConnectyCube.init(CREDENTIALS, CONFIG);
enggomarpu commented 2 years ago

@DaveLomber thanks for your input. It is working fine now. But is there any API of Connectycube, which can tell user online status, if we pass user id ?

DaveLomber commented 2 years ago

https://developers.connectycube.com/js/messaging?id=get-last-activity

and

https://developers.connectycube.com/js/messaging?id=last-activity-subscription