I am trying to figure out how to run background service in react native (Android). Is it possible to run code (e.g. socket listener) while app is running in background or not. I
On Android
Yes, it can be done. Check this link for more information. Basically, you have to enable a notification to "wake" the device when receiving information.
On iOS
Yes, it can be done too, but through hacks. Check these links on SO to have a deeper understanding of these hacks
Play a silent sound and set the background mode to audio. Check this answer for more information on the matter.
Use VoIP services. Check more here but it'll require you justify a VoIP service to Apple.