I am using XMPP.js inside react native and using web socket to connect with the xmpp server. I can successfully connect with the chat server but I have to navigate to different pages inside the App so I have 2 options:
I must open a new XMPP connection to the xmpp chat server everytime I navigate to a new page (using react Navigation for navigating) and close the old connection [I think its not recommended] or
I must open the connection in the starting and use the same connection throughout the entire app. But how to achieve that?
Is there any alternative like services in react native with which I can open the XMPP connection in the backend and it must work throughout the entire app. I need the feasible solution for both Android+IOS