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

if i try to send message after some time from customer side app , the message was not sent into other driver side app. #291

Closed ParmarJigarr closed 2 years ago

ParmarJigarr commented 2 years ago

if i try to send message after some time from customer side app (app was idle for about 10 minutes) , the message was not sent into other driver side app. i need to kill the app and reopen app the it will work fine

ccvlad commented 2 years ago

Hi @ParmarJigarr Device's OS closes chat connection after some time in inactive state. I suggest you import '@react-native-community/netinfo' and listen to internet connection. Do ConnectyCube.chat.disconnect() when your app losses internet connection and call ConnectyCube.chat.connect(params) after the internet becomes online.

ParmarJigarr commented 2 years ago

okay so where i have to do this code of internet connection ? on press of send message of somewhere else ? also my internet connection is on still i have to perform this step ?

DaveLomber commented 2 years ago

You have to put it inside some service class file

because it's a listener

import NetInfo from "@react-native-community/netinfo";

// Subscribe
const unsubscribe = NetInfo.addEventListener(state => {
  console.log("Connection type", state.type);
  console.log("Is connected?", state.isConnected);
});

// Unsubscribe
unsubscribe();