How to publishAudio after closing and reopening the react-native app?

Hey,
I have a react-native app,
When I connect to a channel/session, i save the channel and the sessionToken in the device storage,
So i can disconnect from a channel after i close the app and open it again using the session from the storage. that works fine!

my problem is:
I’m trying to save the mainStreamManager in the storage also,
so i can call the method “publishAudio(true)” after i close the app and open it again.
But i can’t do it.
What should i do?
Should i publishAudio from the server? Is there a way to do it?

Hi,

I don’t know what is happening exactly when the app is going to background and come back to foreground. I don’t know if the session closes or is still alive.

However, you could replace your mainStreamManager by a new one. Initializing another publisher and connect it to the session.

This could be enough to keep publishing your audio and video

How can i Initialize another publisher and set it without joining a channel?
should i use a new instance of openVidu?

https://docs.openvidu.io/en/2.15.0/cheatsheet/publish-unpublish/#publishunpublish-a-stream

i saw that,
When i restart the app the state get cleared,
Let’s say i am initializing another publisher,
How can i connect it to the session if i don’t have one as the state got cleared?

To be honest, I don’t understand your question.

  1. If you want to join a session, read this: https://docs.openvidu.io/en/2.15.0/cheatsheet/join-session/#join-a-session

  2. If you want to publish a stream, read this: https://docs.openvidu.io/en/2.15.0/cheatsheet/join-session/#join-a-session