'How to run certain code in react native expo when the app is running or backgrounded or even killed from the recent apps

I am building chat application in react native (expo) in the frontend and node js with socket.io in backend. In order to update the messages or acknowledgements, I need to make the app to run all the time (active or backgrounded or killed). Is there any way, to acheive this? I have tried expo-task-manager and expo-backgound-fetch, but I didn't get the expected results. Suggest some ideas with steps and explanations. Thank you!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source