Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make socket-io work even after app close

I have been building a chat application in react native. For the bi-directional communication i have used socket-io. Socket-io works only when the app is in foreground, it doesn't work when the app is in background or closed channel disconnects. So how do i keep channel connected even when the app is in background or closed. Is there any background services in react native.

like image 995
Tejas Avatar asked Dec 31 '25 13:12

Tejas


1 Answers

You can use HeadlessJSTask for android to ensure a service is always working while you app is in background. However there is no such thing in iOS and also iOS is very strict with background jobs so you need to accept iOS as it is. Please update here if you find any such thing for iOS. Would be glad to learn.

like image 164
Suraj Malviya Avatar answered Jan 04 '26 16:01

Suraj Malviya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!