React Native - Keep app running when it's killed or closed

Viewed 378

this question may seem duplicate, but I've searched a lot, but could not find any appropriate solution.

I need my socket connection to not break when user kills/closes app. It works when user presses the home button and apps goes to background. But connection breaks when user kills or closes the app. I need behavior like how chat apps like whatsapp literally work. So when I close the whatsapp, I can still receive new messages.

If anyone has found any solution for this, please share. Thank you.

1 Answers

Your Socket connection should run as a background task and continuously listen to stream of message events even when the app close then you can push notifications to notify the user.

https://github.com/jamesisaac/react-native-background-task provide an abstract layer for both iOS and Android

Related